Skip to content

Preserve step colors when converting lower-bound indices to a linear colormap - #251

Open
Hugohong258 wants to merge 1 commit into
python-visualization:mainfrom
Hugohong258:fix-linear-from-lower-bounds
Open

Hugohong258 wants to merge 1 commit into
python-visualization:mainfrom
Hugohong258:fix-linear-from-lower-bounds

Conversation

@Hugohong258

Copy link
Copy Markdown

A StepColormap can take one lower bound per color, but to_linear() always interpreted the last bound as an upper bound. With three colors and bounds [0, 1, 4] the middle color disappeared, and with two colors the conversion raised ZeroDivisionError.

Supply the missing upper bound before selecting the sampling positions. A single-color map can use the same color at both ends of the linear scale. The regression cases compare implicit and explicit upper bounds and check that the original index is preserved.

All 18 colormap tests passed on Windows with Python 3.12.3.

This branch has not been deployed

No deployments
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.

1 participant