Skip to content

Keep category colors in sync when filtering tables - #1277

Open
syahra712 wants to merge 3 commits into
scverse:mainfrom
syahra712:fix/filter-table-category-colors
Open

syahra712 wants to merge 3 commits into
scverse:mainfrom
syahra712:fix/filter-table-category-colors

Conversation

@syahra712

@syahra712 syahra712 commented Oct 16, 2026 •

Copy link
Copy Markdown

Closes #1271

Following the suggestion in the issue: _inplace_fix_subset_categorical_obs already restores the original categories of a filtered table, and it now also restores uns["<column>_colors"] from the original table. The colors are only copied when the original list has one color per category, so a palette that was already out of sync is left alone.

This helper is shared by the joins in relational_query.py, so the fix applies to every path that goes through it: bounding_box_query / polygon_query with filter_table=True, and the join functions.

The test reproduces the issue's example: three cells of types A, C and B, with B outside the query box. Categories stay ['A', 'B', 'C'], and the colors are again ['red', 'green', 'blue'] instead of ['red', 'blue'].

LLM disclosure (scverse AI policy): Claude Opus 5.5 via Claude Code was used to write this change; the new test and the existing query/operations tests (517 passed) were run locally.

@codecov

codecov Bot commented Oct 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.42%. Comparing base (4d19f7d) to head (2efdf22).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1277   +/-   ##
=======================================
  Coverage   91.42%   91.42%           
=======================================
  Files          53       53           
  Lines        8381     8388    +7     
=======================================
+ Hits         7662     7669    +7     
  Misses        719      719           
Files with missing lines Coverage Δ
src/spatialdata/_utils.py 85.88% <100.00%> (+0.60%) ⬆️
🚀 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.

bounding_box_query(filter_table=True) restores dropped categories but not their colors in uns

1 participant