From 37e22ad64d039df72b5eee9cac55d7eecd5b0461 Mon Sep 17 00:00:00 2001 From: Ilia Kats Date: Fri, 1 Oct 2021 15:56:08 +0200 Subject: [PATCH] tissue segmentation: don't crash when no coordinates are found --- SpatialDE/dp_hmrf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SpatialDE/dp_hmrf.py b/SpatialDE/dp_hmrf.py index 14bc7d7..c2fd4d8 100644 --- a/SpatialDE/dp_hmrf.py +++ b/SpatialDE/dp_hmrf.py @@ -257,7 +257,6 @@ def tissue_segmentation( fnclasses = tf.cast(nclasses, dtype=dtype) sizefactors = tf.convert_to_tensor(sizefactors[np.newaxis, :], dtype=dtype) - X = tf.convert_to_tensor(X, dtype=dtype) gamma_1 = tf.convert_to_tensor(params.gamma_1, dtype=dtype) gamma_2 = tf.convert_to_tensor(params.gamma_2, dtype=dtype) @@ -270,6 +269,7 @@ def tissue_segmentation( distances = None if X is not None and (params.neighbors is None or params.neighbors > 0): + X = tf.convert_to_tensor(X, dtype=dtype) distances = square_distance(X, None) if params.neighbors is not None and params.neighbors < nsamples: distances, indices = tf.math.top_k(-distances, k=params.neighbors + 1, sorted=True)