Skip to content

Raise on color name collision with column in render_*#665

Merged
timtreis merged 3 commits into
mainfrom
fix/issue-619-color-column-collision
May 14, 2026
Merged

Raise on color name collision with column in render_*#665
timtreis merged 3 commits into
mainfrom
fix/issue-619-color-column-collision

Conversation

@timtreis
Copy link
Copy Markdown
Member

@timtreis timtreis commented May 14, 2026

Summary

  • Closes color='orange' silently uses literal color instead of column when names collide #619.
  • When color=<str> was both a valid matplotlib color name and a column name in the element or an annotating table, the literal color silently won and the column was ignored (only a default-hidden logger.info was emitted). The user got an all-orange plot with no signal.
  • Now raises ValueError naming the conflicting column location. Disambiguation: pass hex ("#ffa500"), an RGB(A) tuple, or rename the column.
  • render_shapes docstring updated to reflect the new contract (previously committed to "literal color has precedence over column").

Behaviour change

This is a user-visible breaking change in the narrow case where a caller's table or element column happens to share a name with a matplotlib color and they passed color="<that name>". Those callers were previously getting silently-wrong plots; they now get a clear error with two escape hatches.

When `color=<str>` was both a valid matplotlib color and a column name
in the element or an annotating table, the literal color silently won
and the column was ignored (only a default-hidden `logger.info` was
emitted). Now raise `ValueError` with disambiguation guidance: pass hex
(e.g. `"#ffa500"`), an RGB(A) tuple, or rename the column.
@timtreis timtreis changed the title Raise on color name collision with column in render_* (#619) Raise on color name collision with column in render_* May 14, 2026
timtreis added 2 commits May 14, 2026 15:30
The three per-render-function tests all routed through the same
`_type_check_params` -> `_check_color_column_collision` call. Collapse
to two tests in `test_utils.py`, one per code path inside the helper:
element-column lookup (points) and annotating-table lookup (shapes).
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.00000% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.61%. Comparing base (3749098) to head (5839770).

Files with missing lines Patch % Lines
src/spatialdata_plot/pl/utils.py 84.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #665      +/-   ##
==========================================
+ Coverage   77.57%   77.61%   +0.03%     
==========================================
  Files          11       11              
  Lines        3581     3605      +24     
  Branches      840      847       +7     
==========================================
+ Hits         2778     2798      +20     
- Misses        480      484       +4     
  Partials      323      323              
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/basic.py 86.60% <ø> (ø)
src/spatialdata_plot/pl/utils.py 67.90% <84.00%> (+0.20%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@timtreis timtreis merged commit 13c3cde into main May 14, 2026
7 of 8 checks passed
@timtreis timtreis deleted the fix/issue-619-color-column-collision branch May 14, 2026 13:59
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.

color='orange' silently uses literal color instead of column when names collide

2 participants