Skip to content

Fix opaque errors for out-of-range sample_colorscale points - #5913

Open
adityajai119 wants to merge 1 commit into
plotly:mainfrom
adityajai119:fix-colors-validate
Open

adityajai119 wants to merge 1 commit into
plotly:mainfrom
adityajai119:fix-colors-validate

Conversation

@adityajai119

Copy link
Copy Markdown

Summary

\sample_colorscale\ indexed past the end of the colorscale when given a sample point above 1, raising an \IndexError. A negative point failed later with an unrelated color-tuples error. Both now raise a clear \PlotlyError.

Changes

  • Normalize iterable sample points to a list before sampling.
  • Validate each sample point is between 0 and 1 and raise a descriptive \PlotlyError.
  • Add focused regression tests and a CHANGELOG entry.

Verification

  • Added tests fail before the fix (\IndexError\ / unrelated \PlotlyError) and pass after.
  • \python -m pytest tests/test_plotly_utils/colors/test_sample_colorscale.py tests/test_core/test_colors/test_colors.py -q\ -> 11 passed.
  • \python -m ruff check\ and
    uff format --check\ clean on changed files.

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