-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and test SpatialData transformation exporter (#3330)
Fixes: * Fix changes from SOMA coordinate axis names to SpatialData coordinate dimension names. * Invert SOMA scene-to-points transform to correctly store SpatialData point-to-scene transformation. * Fix type annotation for GeoPandas `GeoDataFrame`. Clean-up: * Import `spatialdata` as `sd`. * Add tests for converting transformations.
- Loading branch information
Showing
3 changed files
with
95 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
import pytest | ||
import somacore | ||
|
||
soma_outgest = pytest.importorskip("tiledbsoma.experimental.outgest") | ||
sd = pytest.importorskip("spatialdata") | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"transform, expected", | ||
[ | ||
( | ||
somacore.IdentityTransform(("x1", "y1"), ("x2", "y2")), | ||
sd.transformations.Identity(), | ||
), | ||
( | ||
somacore.UniformScaleTransform(("x1", "y1"), ("x2", "y2"), 10), | ||
sd.transformations.Scale([10, 10], ("x", "y")), | ||
), | ||
( | ||
somacore.ScaleTransform(("x1", "y1"), ("x2", "y2"), [4, 0.1]), | ||
sd.transformations.Scale([4, 0.1], ("x", "y")), | ||
), | ||
( | ||
somacore.AffineTransform( | ||
["x1", "y1"], | ||
["x2", "y2"], | ||
[[2, 2, 0], [0, 3, 1]], | ||
), | ||
sd.transformations.Affine( | ||
np.array([[2, 2, 0], [0, 3, 1], [0, 0, 1]]), ("x", "y"), ("x", "y") | ||
), | ||
), | ||
], | ||
) | ||
def test_transform_to_spatial_data(transform, expected): | ||
input_dim_map = {"x1": "x", "y1": "y", "z1": "z"} | ||
output_dim_map = {"x2": "x", "y2": "y", "z2": "z"} | ||
actual = soma_outgest._transform_to_spatial_data( | ||
transform, input_dim_map, output_dim_map | ||
) | ||
assert actual == expected |