Testing utilities#
- spatialdata.testing.assert_spatial_data_objects_are_identical(sdata0, sdata1, check_transformations=True, check_metadata=True)[source]#
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.
- sdata0
- Return type:
- Returns:
None
- Raises:
AssertionError – If the two SpatialData objects are not identical.
Notes
If
check_metadataisTruebutcheck_transformationsisFalse, 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)[source]#
Compare two elements (two SpatialElements or two tables) and assert that they are identical.
- Parameters:
- element0
SpatialElement|AnnData The first element.
- element1
SpatialElement|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.
- element0
- Return type:
- 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)[source]#
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,.imagesand.tablesproperties.- Parameters:
- elements0
Images|Labels|Shapes|Points|Tables The first dictionary of elements.
- elements1
Images|Labels|Shapes|Points|Tables 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.
- elements0
- Return type:
- 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.