Skip to content

Parameter palette can now be used without specifying groups#659

Merged
timtreis merged 1 commit into
scverse:mainfrom
SAY-5:SAY-5/fix/palette-list-without-groups
May 12, 2026
Merged

Parameter palette can now be used without specifying groups#659
timtreis merged 1 commit into
scverse:mainfrom
SAY-5:SAY-5/fix/palette-list-without-groups

Conversation

@SAY-5
Copy link
Copy Markdown
Contributor

@SAY-5 SAY-5 commented May 12, 2026

Closes #605.

_validate_render_params raised ValueError: When specifying 'palette', 'groups' must also be specified whenever palette=list was supplied without groups=. The dict path has no such restriction, so a list of three colors against three categories forced users to redundantly re-list every category just to satisfy validation.

Dropped the groups is None requirement; the existing length check at _get_colors_for_categorical_obs already raises if the list does not match the category count, and the natural-order mapping there now applies. Regression test in test_render_shapes.py asserts the legend matches the underlying categories.

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 77.48%. Comparing base (53abe71) to head (ccb5905).

Files with missing lines Patch % Lines
src/spatialdata_plot/pl/utils.py 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #659      +/-   ##
==========================================
- Coverage   77.50%   77.48%   -0.02%     
==========================================
  Files          11       11              
  Lines        3569     3567       -2     
  Branches      837      836       -1     
==========================================
- Hits         2766     2764       -2     
+ Misses        481      480       -1     
- Partials      322      323       +1     
Files with missing lines Coverage Δ
src/spatialdata_plot/pl/utils.py 67.58% <0.00%> (+0.01%) ⬆️

... 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 316e2ca into scverse:main May 12, 2026
7 of 8 checks passed
@timtreis timtreis changed the title fix: allow list palette without groups Parameter palette can now be used without specifying groups May 12, 2026
@timtreis
Copy link
Copy Markdown
Member

Hey @SAY-5, thank you for your contribution.

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.

palette=["red","blue",...] raises ValueError unless groups= is also specified

3 participants