Testing utilities#
- spatialdata.testing.assert_spatial_data_objects_are_identical(sdata0, sdata1, check_transformations=True, check_metadata=True)#
Compare two SpatialData objects and assert that they are identical.
- Parameters:
sdata0 (
SpatialData
) – The first SpatialData object.sdata1 (
SpatialData
) – The second SpatialData object.check_transformations (
bool
(default:True
)) – Whether to check if the transformations are identical, for each element.check_metadata (
bool
(default:True
)) – Whether to check if the metadata is identical, for each element.
- Return type:
None
- Returns:
: None
- Raises:
AssertionError – If the two SpatialData objects are not identical.
Notes
If
check_metadata
isTrue
butcheck_transformations
isFalse
, the metadata will be compared with the exclusion of the transformations.With the current implementation, the transformations Translate([1.0, 2.0], axes=(‘x’, ‘y’)) and Translate([2.0, 1.0], axes=(‘y’, ‘x’)) are considered different. A quick way to avoid an error in this case is to use the check_transformations=False parameter.
- spatialdata.testing.assert_elements_are_identical(element0, element1, check_transformations=True, check_metadata=True)#
Compare two elements (two SpatialElements or two tables) and assert that they are identical.
- Parameters:
element0 (
DataArray
|DataTree
|GeoDataFrame
|DataFrame
|AnnData
) – The first element.element1 (
DataArray
|DataTree
|GeoDataFrame
|DataFrame
|AnnData
) – The second element.check_transformations (
bool
(default:True
)) – Whether to check if the transformations of the elements are identical.check_metadata (
bool
(default:True
)) – Whether to check if the metadata of the elements is identical.
- Return type:
None
- Returns:
: None
- Raises:
AssertionError – If the two elements are not identical.
Notes
Please see
spatialdata.testing.assert_spatial_data_objects_are_identical()
for additional comments.
- spatialdata.testing.assert_elements_dict_are_identical(elements0, elements1, check_transformations=True, check_metadata=True)#
Compare two dictionaries of elements and assert that they are identical (except for the order of the keys).
The dictionaries of elements can be obtained from a SpatialData object using the
.shapes
,.labels
,.points
,.images
and.tables
properties.- Parameters:
elements0 (
Elements
) – The first dictionary of elements.elements1 (
Elements
) – The second dictionary of elements.check_transformations (
bool
(default:True
)) – Whether to check if the transformations are identical, for each element.check_metadata (
bool
(default:True
)) – Whether to check if the metadata is identical, for each element.
- Return type:
None
- Returns:
: None
- Raises:
AssertionError – If the two dictionaries of elements are not identical.
Notes
Please see
spatialdata.testing.assert_spatial_data_objects_are_identical()
for additional comments.