matplotlib / cmocean

Colormap setup for standardizing commonly-plotting oceanographic variables.
MIT License
230 stars 52 forks source link

ENH: work around pending deprecation warnings in MPL #86

Closed neutrinoceros closed 1 year ago

neutrinoceros commented 1 year ago

fix #83

notes:

neutrinoceros commented 1 year ago

reprod:

run pytest -Werror t.py with

# t.py
import cmocean

on the master branch + matplotlib 3.6, it fails with

========================= test session starts =========================
platform darwin -- Python 3.11.1, pytest-7.2.0, pluggy-1.0.0
rootdir: /Users/robcleme/dev/cmocean
collected 0 items / 1 error

=============================== ERRORS ================================
________________________ ERROR collecting t.py ________________________
t.py:1: in <module>
    import cmocean
cmocean/__init__.py:11: in <module>
    from . import cm, tools, data
cmocean/cm.py:43: in <module>
    cm.register_cmap(cmap = reg_map)
../../.pyenv/versions/cmocean-dev/lib/python3.11/site-packages/matplotlib/_api/deprecation.py:199: in wrapper
    emit_warning()
../../.pyenv/versions/cmocean-dev/lib/python3.11/site-packages/matplotlib/_api/deprecation.py:193: in emit_warning
    warn_deprecated(
../../.pyenv/versions/cmocean-dev/lib/python3.11/site-packages/matplotlib/_api/deprecation.py:96: in warn_deprecated
    warn_external(warning, category=MatplotlibDeprecationWarning)
../../.pyenv/versions/cmocean-dev/lib/python3.11/site-packages/matplotlib/_api/__init__.py:363: in warn_external
    warnings.warn(message, category, stacklevel)
E   PendingDeprecationWarning: The register_cmap function will be deprecated in a future version. Use ``matplotlib.colormaps.register(name)`` instead.
======================= short test summary info =======================
ERROR t.py - PendingDeprecationWarning: The register_cmap function will be depr...
!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!
========================== 1 error in 0.25s ===========================

on this branch it runs fine

kthyng commented 1 year ago

Hi @neutrinoceros and thanks so much for your work on this!

I'm not sure about what Python version we should support. I see this page from matplotlib which shows 3.8 is fine for the recent matplotlib version, but not the last one.

Matplotlib Python NumPy
3.6 3.8 1.19.0
3.5 3.7 1.17.0

I think it is fine to follow matplotlib's lead and for the newest version of cmocean, support Python 3.8 as a minimum version.