SmileiPIC / Smilei

Particle-in-cell code for plasma simulation
https://smileipic.github.io/Smilei
344 stars 120 forks source link

Deprecated pyplot register_cmap #722

Closed hwlr0 closed 5 months ago

hwlr0 commented 5 months ago

Description

I just messed with my VM and had to reinstall everything. It appears that the latest version of Matplotlib (3.9.0) is not compatible with happi. Indeed, happi uses the function matplotlib.pyplot.register_cmap, which is not present in matplotlib anymore:

https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.6.0.html#pending-deprecation-top-level-cmap-registration-and-access-functions-in-mpl-cm https://github.com/matplotlib/matplotlib/issues/20853

Steps to reproduce the problem

Just try to happi.Open() a simulation with matplotlib v3.9.

  File "/home/wsl_howel/Smilei/happi/_Utils.py", line 45, in register
    matplotlib.pyplot.register_cmap(cmap=cmap)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: module 'matplotlib.pyplot' has no attribute 'register_cmap'

Parameters

mccoys commented 5 months ago

Thanks for the report. Will fix soon. In the meantime you can replace the function by matplotlib.colormaps.register(cmap)

hwlr0 commented 5 months ago

Okay, thanks

mccoys commented 5 months ago

Should be solved in branch develop. Please reopen if it persists