Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/spatialdata/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ def parse(
:class:`spatial_image.SpatialImage` or
:class:`multiscale_spatial_image.MultiscaleSpatialImage`.
"""
if transformations:
transformations = transformations.copy()
if "name" in kwargs:
raise ValueError("The `name` argument is not (yet) supported for raster data.")
# if dims is specified inside the data, get the value of dims from the data
Expand Down
18 changes: 17 additions & 1 deletion tests/core/operations/test_spatialdata_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
from spatial_image import SpatialImage
from spatialdata import SpatialData
from spatialdata._core.concatenate import _concatenate_tables, concatenate
from spatialdata.datasets import blobs
from spatialdata.models import (
Image2DModel,
Labels2DModel,
PointsModel,
ShapesModel,
TableModel,
)
from spatialdata.transformations.operations import set_transformation
from spatialdata.transformations.operations import get_transformation, set_transformation
from spatialdata.transformations.transformations import Identity, Scale

from tests.conftest import _get_table
Expand Down Expand Up @@ -239,3 +240,18 @@ def test_set_item(full_sdata):
# trying to overwrite the file used for backing (only for images, labels and points)
with pytest.raises(ValueError):
full_sdata[name] = full_sdata[name]


def test_no_shared_transformations():
"""Test transformation dictionary copy for transformations not to be shared."""
sdata = blobs()
element_name = "blobs_image"
test_space = "test"
set_transformation(sdata.images[element_name], Identity(), to_coordinate_system=test_space)

gen = sdata._gen_elements()
for _, name, obj in gen:
if name != element_name:
assert test_space not in get_transformation(obj, get_all=True)
else:
assert test_space in get_transformation(obj, get_all=True)