`plotly.colors.validate_colors` fails for valid colors and passes for invalid colors
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 18.8k
- Forks
- 2.8k
- Avg merge
- 16h 26m
- Merged PRs (30d)
- 21
Description
This function raises a PlotlyError for color formats that are valid within traces, but also does not raise errors for color formats that are not valid.
Example of a valid color string that does not pass: color = 'hsl(290, 100%, 50%)'. This works perfectly fine if you construct a trace with it, but fails the validation test because it does not contain "rgb" or "#".
import plotly.graph_objects as go
import plotly.colors as pc
color = 'hsl(290, 100%, 50%)'
# this works
trace = go.Scatter(x=[0], y=[0], marker=dict(color=color))
fig = go.Figure(trace)
fig.show()
# this does not
pc.validate_colors(color) # this throws an error
Other cases:
- A valid, named color string throws an error
- The same named color within a list does not throw an error
- An invalid named color within a list does not throw an error, but it should
Examples below
import plotly.colors as pc
pc.validate_colors('red') # throws PlotlyError
pc.validate_colors(['red'])
>>> ['red']
pc.validate_colors(['asdflkjlaskdg'])
>>> ['asdflkjlaskdg']
Perhaps this function is not meant to be used in this way? If so then more information in the docstrings could be helpful.
Plotly version 5.24.1.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the plotly.colors.validate_colors entry point and reproduce the HSL, named-color, valid-list, and invalid-list examples from the issue. Trace how scalar and list inputs are validated. Done means valid trace-supported colors are accepted, invalid colors are rejected consistently, and the function's intended usage is clear in its documentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100