`plotly.colors.validate_colors` fails for valid colors and passes for invalid colors
还没有人认领这个 Issue。
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
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.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 plotly.colors.validate_colors 入口开始,复现 issue 中的 HSL、named-color、valid-list 和 invalid-list 示例。跟踪标量输入和列表输入的验证方式。当支持 trace 的有效颜色能够被接受、无效颜色能够被一致地拒绝,并且函数的预期用法在文档中清晰明确时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100