python-visualization / python-visualization/branca

Colors given as tuple of ints are not working anymore for LinearColormap and StepColormap since v0.8.0

Offen
#190 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

bug
Vorherrschende Sprache
Python
Sterne
134
Forks
69
Ø Merge
1 Std. 10 Min.
Gemergte PRs (30 T.)
1

Beschreibung

When I create a LinearColormap or a StepColormap with a list of tuples of ints as argument for the colors parameter, it is no longer converted to floats and leads to incorrect results.

Current behaviour (v0.8.0 v0.8.1):

>>> from branca.colormap import LinearColormap
>>> colormap = LinearColormap(colors=[(128, 64, 255), (255, 128, 0)])
>>> colormap.colors
[(128, 64, 255, 1.0), (255, 128, 0, 1.0)]
>>> colormap.rgb_bytes_tuple(0)
(32767, 16383, 65279)
>>> colormap.rgba_floats_tuple(1)
(255, 128, 0, 1.0)

Expected behaviour (v0.7.2):

>>> from branca.colormap import LinearColormap
>>> colormap = LinearColormap(colors=[(128, 64, 255), (255, 128, 0)])
>>> colormap.colors
[(0.5019607843137255, 0.25098039215686274, 1.0, 1.0), (1.0, 0.5019607843137255, 0.0, 1.0)]
>>> colormap.rgb_bytes_tuple(0)
(128, 64, 255)
>>> colormap.rgba_floats_tuple(1)
(1.0, 0.5019607843137255, 0.0, 1.0)

This seems to be due to the internal _parse_color function that was broken in https://github.com/python-visualization/branca/commit/8a8a2141c13947f6afaaf65a8c29c4417cd3a5a3#diff-6886114fc8e4fd6197705978c768e1f49469e2455fb1c4a8efda26a7b11bfa0bL51.

Current behaviour (v0.8.0 v0.8.1):

>>> from branca.colormap import _parse_color
>>> _parse_color((128, 64, 255))
(128, 64, 255, 1.0)

Expected behaviour (v0.7.2):

>>> from branca.colormap import _parse_color
>>> _parse_color((128, 64, 255))
(0.5019607843137255, 0.25098039215686274, 1.0, 1.0)

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

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

Beginne bei branca.colormap._parse_color und verfolge, wie LinearColormap und StepColormap ihre Farben durch diese Funktion leiten. Reproduziere die Integer-Tupel-Beispiele aus dem Issue und überprüfe anschließend, dass Tupel in Gleitkomma-Farbwerte normalisiert werden und dass rgb_bytes_tuple und rgba_floats_tuple für beide Colormap-Typen die erwarteten Ergebnisse liefern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data-visualization
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

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