@@ -198,25 +198,23 @@ def test_radius_min_max(self, non_visium_adata: AnnData, radius: tuple[float, fl
198198 np .testing .assert_allclose (spatial_dist , gt_ddist )
199199
200200 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 )
202202
203- assert isspmatrix_csr (conn )
204- assert isspmatrix_csr (dist )
203+ assert isspmatrix_csr (result . connectivities )
204+ assert isspmatrix_csr (result . distances )
205205 assert Key .obsp .spatial_conn () not in non_visium_adata .obsp
206206 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 )
209209
210210 @pytest .mark .parametrize ("percentile" , [99.0 , 95.0 ])
211211 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 )
216214
217215 # 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 ()
220218
221219 Adj , Dst = _build_connectivity (adata_hne .obsm ["spatial" ], n_neighs = 6 , return_distance = True , set_diag = False )
222220 threshold = np .percentile (Dst .data , percentile )
@@ -225,7 +223,7 @@ def test_percentile_filtering(self, adata_hne: AnnData, percentile: float, coord
225223 Adj .eliminate_zeros ()
226224 Dst .eliminate_zeros ()
227225
228- assert dist_filtered .max () == Dst .max ()
226+ assert result_filtered . distances .max () == Dst .max ()
229227
230228 @pytest .mark .parametrize ("n_neighs" , [5 , 10 , 20 ])
231229 def test_spatial_neighbors_generic (self , n_neighs : int ):
0 commit comments