plotly / plotly/plotly.py

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

Offen
#4,957 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug P2
Vorherrschende Sprache
Python
Sterne
18.8k
Forks
2.8k
Ø Merge
16 Std. 26 Min.
Gemergte PRs (30 T.)
21

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginnen Sie am Einstiegspunkt plotly.colors.validate_colors und reproduzieren Sie die HSL-, named-color-, valid-list- und invalid-list-Beispiele aus dem Issue. Verfolgen Sie, wie skalare und Listen-Eingaben validiert werden. Als abgeschlossen gilt dies, wenn gültige von Traces unterstützte Farben akzeptiert, ungültige Farben konsistent abgelehnt werden und die vorgesehene Verwendung der Funktion in ihrer Dokumentation klar ist.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.