Repository navigation
Fix error when a color palette is shorter than the category list - #409
Draft
AlbertoFabbri93 wants to merge 1 commit into
Draft
AlbertoFabbri93 wants to merge 1 commit into
AlbertoFabbri93 wants to merge 1 commit into
Conversation
Coloring a layer by a categorical obs column paired the palette in
uns["<column>_colors"] with the column's categories using a strict zip.
When the table rows annotating an element do not use every category,
the colors of the unused categories have already been dropped from the
palette while the column still declares all of them, so the zip raised:
ValueError: zip() argument 2 is shorter than argument 1
Pair the palette with the used categories when its length matches
theirs, so each category keeps its color. If the palette matches
neither the full nor the used category list, raise an error naming the
palette, its number of colors and the number of categories.
Add a test that colors a labels layer by a column with four categories,
two of them used, and a two-color palette.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #409 +/- ##
==========================================
+ Coverage 63.08% 72.17% +9.09%
==========================================
Files 19 19
Lines 2636 3404 +768
==========================================
+ Hits 1663 2457 +794
+ Misses 973 947 -26 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Coloring a layer by a categorical obs column paired the palette in
uns["<column>_colors"]with the column's categories using a strict zip. When the table rows annotating an element do not use every category, the colors of the unused categories have already been dropped from the palette while the column still declares all of them, so the zip raised:Pair the palette with the used categories when its length matches theirs, so each category keeps its color. If the palette matches neither the full nor the used category list, raise an error naming the palette, its number of colors and the number of categories.
Add a test that colors a labels layer by a column with four categories, two of them used, and a two-color palette.