You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing the ptypy.utils module fails with matplotlib versions equal to or newer than 3.6 due to deprecation of the matplotlib.cm.register_cmap function.
How to reproduce the bug
fromptypyimportutilsasu
The above script produces the following stack trace:
---------------------------------------------------------------------------AttributeErrorTraceback (mostrecentcalllast)
CellIn[1], line1---->1fromptypyimportutilsasuFile~/src/leb/ptytest/.venv/lib/python3.12/site-packages/ptypy/__init__.py:4542delmatplotlib44# Initialize MPI (eventually GPU)--->45from .utilsimportparallel47# Logging48from .utilsimportverboseFile~/src/leb/ptytest/.venv/lib/python3.12/site-packages/ptypy/utils/__init__.py:2119from .. import__has_matplotlib__ashmpl20ifhmpl:
--->21from .plot_utilsimport*22from .plot_clientimportPlotClient, MPLClient, spawn_MPLClient, MPLplotter23delhmplFile~/src/leb/ptytest/.venv/lib/python3.12/site-packages/ptypy/utils/plot_utils.py:419379# Removing it due to DeprecationWarning in Matplotlib380# DeprecationWarning: Passing raw data via parameters data and lut to register_cmap() is deprecated since 3.3 and will become an error two minor releases later. Instead use: register_cmap(cmap=LinearSegmentedColormap(name, data, lut))381# Franz map
(...)
399400# Franz Map401franzmap_cm= {'red': ((0.000, 0, 0),
402 (0.350, 0, 0),
403 (0.660, 1, 1),
(...)
416 (0.650, 0, 0),
417 (1.000, 0, 0))}
-->419mpl.cm.register_cmap(cmap=LinearSegmentedColormap(name='franzmap', segmentdata=franzmap_cm, N=256))
421deffranzmap():
422 \"\"\"\\423SetthedefaultcolormaptoFranz'smapandapplytocurrentimageifany.
424 \"\"\"AttributeError: module'matplotlib.cm'hasnoattribute'register_cmap'"
Hi @kmdouglass,
Thank you for the message. That issue was already solved in the branch dev (#555).
You can install the branch dev. A new patch with the solution is expected to be released soon.
Importing the
ptypy.utils
module fails with matplotlib versions equal to or newer than 3.6 due to deprecation of thematplotlib.cm.register_cmap
function.How to reproduce the bug
The above script produces the following stack trace:
Cause
matplotlib.cm.register_cmap
was removed in Matplotlib 3.6: https://matplotlib.org/3.6.3/api/cm_api.html#matplotlib.cm.register_cmapPossible solution
As stated in the documentation at the link above, use
matplotlib.colormaps.register(name)
instead.Environment
The text was updated successfully, but these errors were encountered: