11import numpy as np
22import pytest
3+ import xarray as xr
34from multiscale_spatial_image import MultiscaleSpatialImage
45
56from metaspace_converter .constants import COORD_SYS_GLOBAL , OPTICAL_IMAGE_KEY , POINTS_KEY , X , Y
@@ -48,18 +49,18 @@ def test_metaspace_to_spatialdata(
4849 )
4950
5051 # Check table
51- assert actual . table is not None
52+ assert " table" in actual . tables
5253 dataset = sm .dataset (id = dataset_id )
53- assert actual .table .n_obs == np .prod (get_ion_image_shape (dataset ))
54- assert actual .table .n_vars == len (dataset .annotations (fdr = fdr , database = database ))
54+ assert actual .tables [ " table" ] .n_obs == np .prod (get_ion_image_shape (dataset ))
55+ assert actual .tables [ " table" ] .n_vars == len (dataset .annotations (fdr = fdr , database = database ))
5556 assert {
5657 COL .ion_image_shape_y ,
5758 COL .ion_image_shape_x ,
5859 COL .ion_image_pixel_y ,
5960 COL .ion_image_pixel_x ,
60- }.issubset (actual .table .obs .columns )
61- assert np .all (actual .table .var ["fdr" ] <= fdr )
62- actual_database = actual .table .uns [METASPACE_KEY ]["metaspace_to_anndata_parameters" ]["database" ]
61+ }.issubset (actual .tables [ " table" ] .obs .columns )
62+ assert np .all (actual .tables [ " table" ] .var ["fdr" ] <= fdr )
63+ actual_database = actual .tables [ " table" ] .uns [METASPACE_KEY ]["metaspace_to_anndata_parameters" ]["database" ]
6364 assert actual_database == list (database )
6465
6566 # Check optical image, if requested
@@ -72,7 +73,7 @@ def test_metaspace_to_spatialdata(
7273 if add_optical_image and add_points :
7374 # All points should be positioned within the image bounds.
7475 points_over_image = actual .transform_element_to_coordinate_system (
75- actual . points [ points_name_added ] , target_coordinate_system = COORD_SYS_GLOBAL
76+ points_name_added , target_coordinate_system = COORD_SYS_GLOBAL
7677 )[[Y , X ]].compute ()
7778 image_min = (0 , 0 )
7879 image_max = _get_image_shape (actual .images [optical_name_added ])
@@ -83,7 +84,7 @@ def test_metaspace_to_spatialdata(
8384
8485
8586def _get_image_shape (image : MultiscaleSpatialImage ) -> tuple [int , int ]:
86- assert isinstance (image , MultiscaleSpatialImage )
87+ assert isinstance (image , xr . DataTree )
8788 sizes = image ["scale0" ].sizes
8889 return sizes ["y" ], sizes ["x" ]
8990
0 commit comments