plotly / plotly/plotly.py

`plotly.colors.validate_colors` fails for valid colors and passes for invalid colors

オープン
#4,957 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. 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

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。