matplotlib / matplotlib/cmocean
`cmocean.tools.print_colormaps` snippet in the docs raises an error
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 269
- Forks
- 54
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Hello! I love your work, this is my favorite set of colormaps.
Today I wanted to run some code from the docs:
import cmocean
cmaps = cmocean.cm.cmap_d
cmocean.tools.print_colormaps(cmaps)
and it produces the following exception and traceback:
Traceback (most recent call last):
File "/home/mfisher/Projects/_test/extend-colormaps-js/test.py", line 4, in <module>
cmocean.tools.print_colormaps(cmaps)
File "/home/mfisher/Projects/_test/extend-colormaps-js/.pixi/envs/default/lib/python3.12/site-packages/cmocean/tools.py", line 25, in print_colormaps
rgbtemp = cmap(np.linspace(0, 1, N))[np.newaxis, :, :3][0]
^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'str' object is not callable
The issue appears to be here:
We loop over the cmaps object, which is a dictionary of colormap name keys to colormap object values in this invocation, but the function expects the object to be a list of colormap objects.
So the docs could be updated to:
import cmocean
cmaps = cmocean.cm.cmap_d
cmocean.tools.print_colormaps(cmaps.values())
But after running this code I don't see the output files!
Beitragsleitfaden
Für dieses Repository ist kein Beitragsleitfaden indexiert
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem im Issue verlinkten capabilities-Beispiel und mit cmocean/tools.py ungefähr bei Zeile 23; führe das dokumentierte Snippet aus und prüfe, wie print_colormaps seine Eingabe verarbeitet und die Ausgabe schreibt. Aktualisiere das Dokumentationsbeispiel so, dass es den gemeldeten Fehler nicht mehr auslöst, und stelle klar oder überprüfe, wo seine Ausgabedateien erscheinen sollen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- documentation
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100