From f9ff81feea0fcf45144cb414da23be43fba09e3c Mon Sep 17 00:00:00 2001 From: Ilia Kats Date: Tue, 21 Sep 2021 13:19:18 +0200 Subject: [PATCH] test: improve speed for AnnData with lots of metadata --- SpatialDE/_internal/tf_dataset.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/SpatialDE/_internal/tf_dataset.py b/SpatialDE/_internal/tf_dataset.py index ea441b4..4284f41 100644 --- a/SpatialDE/_internal/tf_dataset.py +++ b/SpatialDE/_internal/tf_dataset.py @@ -30,11 +30,10 @@ def __init__( def __call__(self): for i, g in enumerate(self.genes): - slice = self.adata[:, i] if self.layer is None: - data = slice.X + data = self.adata.X[:, i] else: - data = slice.layers[self.layer] + data = self.adata.layers[self.layer][:, i] if issparse(data): data = data.toarray() with tf.device(tf.DeviceSpec(device_type="CPU").to_string()):