@@ -198,25 +198,23 @@ def test_radius_min_max(self, non_visium_adata: AnnData, radius: tuple[float, fl
198
198
np .testing .assert_allclose (spatial_dist , gt_ddist )
199
199
200
200
def test_copy (self , non_visium_adata : AnnData ):
201
- conn , dist = spatial_neighbors (non_visium_adata , delaunay = True , coord_type = None , copy = True )
201
+ result = spatial_neighbors (non_visium_adata , delaunay = True , coord_type = None , copy = True )
202
202
203
- assert isspmatrix_csr (conn )
204
- assert isspmatrix_csr (dist )
203
+ assert isspmatrix_csr (result . connectivities )
204
+ assert isspmatrix_csr (result . distances )
205
205
assert Key .obsp .spatial_conn () not in non_visium_adata .obsp
206
206
assert Key .obsp .spatial_dist () not in non_visium_adata .obsp
207
- np .testing .assert_allclose (dist .toarray (), self ._gt_ddist )
208
- np .testing .assert_allclose (conn .toarray (), self ._gt_dgraph )
207
+ np .testing .assert_allclose (result . distances .toarray (), self ._gt_ddist )
208
+ np .testing .assert_allclose (result . connectivities .toarray (), self ._gt_dgraph )
209
209
210
210
@pytest .mark .parametrize ("percentile" , [99.0 , 95.0 ])
211
211
def test_percentile_filtering (self , adata_hne : AnnData , percentile : float , coord_type = "generic" ):
212
- conn , dist = spatial_neighbors (adata_hne , coord_type = coord_type , copy = True )
213
- conn_filtered , dist_filtered = spatial_neighbors (
214
- adata_hne , coord_type = coord_type , percentile = percentile , copy = True
215
- )
212
+ result = spatial_neighbors (adata_hne , coord_type = coord_type , copy = True )
213
+ result_filtered = spatial_neighbors (adata_hne , coord_type = coord_type , percentile = percentile , copy = True )
216
214
217
215
# check whether there are less connectivities in the filtered graph and whether the max distance is smaller
218
- assert not ((conn != conn_filtered ).nnz == 0 )
219
- assert dist . max () > dist_filtered .max ()
216
+ assert not ((result . connectivities != result_filtered . connectivities ).nnz == 0 )
217
+ assert result . distances . max () > result_filtered . distances .max ()
220
218
221
219
Adj , Dst = _build_connectivity (adata_hne .obsm ["spatial" ], n_neighs = 6 , return_distance = True , set_diag = False )
222
220
threshold = np .percentile (Dst .data , percentile )
@@ -225,7 +223,7 @@ def test_percentile_filtering(self, adata_hne: AnnData, percentile: float, coord
225
223
Adj .eliminate_zeros ()
226
224
Dst .eliminate_zeros ()
227
225
228
- assert dist_filtered .max () == Dst .max ()
226
+ assert result_filtered . distances .max () == Dst .max ()
229
227
230
228
@pytest .mark .parametrize ("n_neighs" , [5 , 10 , 20 ])
231
229
def test_spatial_neighbors_generic (self , n_neighs : int ):
0 commit comments