Skip to content

Fix render_shapes losing transformation after groups filtering#564

Open
timtreis wants to merge 1 commit intomainfrom
fix/issue-420-groups-transform
Open

Fix render_shapes losing transformation after groups filtering#564
timtreis wants to merge 1 commit intomainfrom
fix/issue-420-groups-transform

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented Mar 29, 2026

Summary

Root cause

In _render_shapes, the transformation was read after groups filtering and a gpd.GeoDataFrame() re-wrap that strips .attrs. With current geopandas/pandas, .attrs happen to survive boolean indexing + reset_index(), but this is documented as experimental. The GeoDataFrame() constructor definitively strips them. Moving the read earlier makes the code robust regardless of pandas .attrs propagation behavior.

Move _prepare_transformation() call to before the groups filtering
block so the coordinate-system transformation is captured while the
element's metadata is still intact.  The GeoDataFrame re-wrap that
follows groups filtering strips .attrs, which would lose the
transformation if read afterwards.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.06%. Comparing base (6b2c484) to head (46b80ce).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #564   +/-   ##
=======================================
  Coverage   74.06%   74.06%           
=======================================
  Files          10       10           
  Lines        2826     2826           
  Branches      651      651           
=======================================
  Hits         2093     2093           
  Misses        457      457           
  Partials      276      276           
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/render.py 82.84% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Plotting cluster sometimes results in coordinate system not being found, even if set correctly

2 participants