SuperDARN / pydarn

Python library for visualizing SuperDARN Data
GNU Lesser General Public License v3.0
31 stars 11 forks source link

Matplotlib version restriction not sufficient #373

Closed aburrell closed 5 months ago

aburrell commented 7 months ago

BUG

pydarn fails on import with matplotlib version 3.4.2 due to the lack of a module called "colormaps". This is fixed by upgrading to matplotlib version 3.8.2.

Priority

Information

python version: 3.9 OS: OS X Big Sur matplotlib version: 3.4.2 (fails); 3.8.2 (succeeds)

Example of the bug

With the older version of matplotlib:

import pydarn

Yields:

File ~/Library/Python/3.9/lib/python/site-packages/pydarn/__init__.py:71
     69 from .plotting.color_maps import PyDARNColormaps
     70 from .plotting.projections import Projs
---> 71 from .plotting.rtp import RTP
     72 from .plotting.fan import Fan
     73 from .plotting.grid import Grid

File ~/Library/Python/3.9/lib/python/site-packages/pydarn/plotting/rtp.py:35
     32 import warnings
     34 from datetime import datetime, timedelta
---> 35 from matplotlib import dates, colors, colormaps, ticker
     36 from typing import List
     38 from pydarn import (RangeEstimation, check_data_type, Coords,
     39                     time2datetime, rtp_exceptions, plot_exceptions,
     40                     SuperDARNCpids, SuperDARNRadars,
     41                     standard_warning_format, PyDARNColormaps)

ImportError: cannot import name 'colormaps' from 'matplotlib' (/opt/local/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/__init__.py)

Attempts

What have you tried already to fix it? Updated the matplotlib version

Data Location

No data file necessary

Potential Bug Location

pydarn.plotting.rtp.py line 35. Probably also other places that contain the matplotlib.colormaps.

Potential Solution(s)

Please note this is not required. 1) You could do a try/except for colormaps and cm as colormaps to be more version agnostic 2) You can increase the minimum supported matplotlib version in setup.cfg (or move these to the pyproject.toml)

Extra Notes

Recommend adding CI tests for different mpl versions to avoid this issue in the future.

carleyjmartin commented 7 months ago

Thanks Angeline! I'll update the requirements.