Skip to content

Extend make_palette_from_data to support labels#670

Merged
timtreis merged 2 commits into
mainfrom
fix/issue-662-make-palette-labels
May 19, 2026
Merged

Extend make_palette_from_data to support labels#670
timtreis merged 2 commits into
mainfrom
fix/issue-662-make-palette-labels

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented May 19, 2026

Summary

  • make_palette_from_data previously raised KeyError for labels (raster) elements — the error message itself flagged it as a known TODO.
  • _resolve_element now dispatches labels through _get_labels_from_table (labels have no per-pixel column; the categorical column always lives on the linked AnnData table).
  • KeyError available-elements set extended to include sdata.labels; obsolete "not yet supported" note removed.
  • Docstring for make_palette_from_data updated to mention labels and clarify the shapes/points-vs-labels lookup rules.

Closes #662

Labels (raster) elements have no per-pixel column, so the categorical
column always lives on the linked AnnData table. Dispatch through
_get_labels_from_table for the labels case; broaden the KeyError to
list labels in the available-elements set.
@timtreis timtreis changed the title Extend make_palette_from_data to support labels (#662) Extend make_palette_from_data to support labels May 19, 2026
Drop hand-rolled _build_labels_sdata / labels_sdata fixture. sdata_blobs
already provides blobs_labels with a linked table; add the categorical
cell_type column on the table directly, matching the existing pattern
in test_render_labels.py.
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.63%. Comparing base (2329522) to head (659640e).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #670      +/-   ##
==========================================
+ Coverage   77.61%   77.63%   +0.01%     
==========================================
  Files          11       11              
  Lines        3610     3612       +2     
  Branches      849      850       +1     
==========================================
+ Hits         2802     2804       +2     
  Misses        485      485              
  Partials      323      323              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/_palette.py 85.31% <100.00%> (+0.73%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis timtreis merged commit 59da170 into main May 19, 2026
7 of 8 checks passed
@timtreis timtreis deleted the fix/issue-662-make-palette-labels branch May 19, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend make_palette_from_data to support labels elements

2 participants