Skip to content

Commit 057bd5c

Browse files
committed
test(shapes): drop version-dependent attrs assertion in #420 regression
test_groups_filtering_preserves_transformation hard-asserted that a bare gpd.GeoDataFrame re-wrap strips .attrs (so _prepare_transformation raises). Whether the GeoDataFrame constructor propagates .attrs is pandas/geopandas version dependent, so that assertion fails on stacks that preserve them. Keep the actual #420 guard (the spatialdata-managed element retains its transform after groups filtering) and drop the brittle demonstration block and now-dead re-wrap.
1 parent 508f5a6 commit 057bd5c

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

‎tests/pl/test_render_shapes.py‎

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1331,10 +1331,10 @@ def test_plot_can_handle_non_numeric_radius_values(sdata_blobs: SpatialData):
13311331
def test_groups_filtering_preserves_transformation(sdata_blobs: SpatialData):
13321332
"""Regression test for #420: groups filtering must not strip coordinate-system metadata.
13331333
1334-
Simulates the exact sequence that ``_render_shapes`` performs —
1334+
Simulates the sequence that ``_render_shapes`` performs —
13351335
filter_by_coordinate_system -> groups boolean-index -> reset_index ->
1336-
re-assign to sdata_filt -> GeoDataFrame re-wrap — then asserts that
1337-
``_prepare_transformation`` can still retrieve the correct transformation.
1336+
re-assign to sdata_filt — then asserts that ``_prepare_transformation``
1337+
can still retrieve the correct transformation.
13381338
"""
13391339
from spatialdata_plot.pl._datashader import _prepare_transformation
13401340

@@ -1354,20 +1354,13 @@ def test_groups_filtering_preserves_transformation(sdata_blobs: SpatialData):
13541354
keep = shapes["cluster"] == "c1"
13551355
shapes = shapes[keep].reset_index(drop=True)
13561356
sdata_filt["blobs_polygons"] = shapes
1357-
# GeoDataFrame re-wrap strips .attrs (this is what _render_shapes does next)
1358-
shapes = gpd.GeoDataFrame(shapes, geometry="geometry")
13591357

13601358
# sdata_filt's element must still carry the correct transformation
13611359
trans, _ = _prepare_transformation(sdata_filt.shapes["blobs_polygons"], cs)
13621360
matrix = trans.get_matrix()
13631361
np.testing.assert_allclose(matrix[0, 0], scale_factor, err_msg="x-scale lost after groups filtering")
13641362
np.testing.assert_allclose(matrix[1, 1], scale_factor, err_msg="y-scale lost after groups filtering")
13651363

1366-
# The GeoDataFrame re-wrap strips attrs — reading the transform from
1367-
# the re-wrapped object must fail, proving why early capture matters.
1368-
with pytest.raises(AssertionError):
1369-
_prepare_transformation(shapes, cs)
1370-
13711364

13721365
def test_plot_can_handle_mixed_numeric_and_color_data(sdata_blobs: SpatialData):
13731366
"""Test that mixed numeric and color-like data raises a clear error."""

0 commit comments

Comments
 (0)