Description
SUITPy 2.1.1 cannot be imported when used with Matplotlib 3.11.
SUITPy currently declares the following dependency in setup.py:
Therefore, pip may install Matplotlib 3.11. However, SUITPy/flatmap.py still imports get_cmap from matplotlib.cm:
from matplotlib.cm import ScalarMappable, get_cmap
matplotlib.cm.get_cmap was removed in Matplotlib 3.11, causing import SUITPy to fail.
Environment
- OS: Linux
- Python: 3.12.14
- SUITPy: 2.1.1
- Matplotlib: 3.11.1
Steps to reproduce
Install the affected versions:
python -m pip install "SUITPy==2.1.1" "matplotlib==3.11.1"
Then try to import SUITPy:
python -c "import SUITPy"
Actual behavior
The import fails with:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../site-packages/SUITPy/__init__.py", line 10, in <module>
from .flatmap import ...
File ".../site-packages/SUITPy/flatmap.py", line 20, in <module>
from matplotlib.cm import ScalarMappable, get_cmap
ImportError: cannot import name 'get_cmap' from 'matplotlib.cm'
This prevents all SUITPy functionality from being used, even when the flatmap plotting functions are not needed.
Expected behavior
import SUITPy should succeed with dependency versions permitted by SUITPy's package metadata.
If Matplotlib 3.11 is not yet supported, the dependency metadata could temporarily specify:
Cause
Matplotlib 3.11 removed matplotlib.cm.get_cmap. The recommended alternatives are matplotlib.colormaps.get_cmap and matplotlib.pyplot.get_cmap.
Matplotlib documents this removal here:
https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.11.0.html#matplotlib-cm-get-cmap
Possible fix
In the current flatmap.py, the imported get_cmap appears to be unused. Colormap lookup is already performed through:
Therefore, the import could likely be changed from:
from matplotlib.cm import ScalarMappable, get_cmap
to:
from matplotlib.cm import ScalarMappable
If get_cmap is required elsewhere in the future, it could instead be obtained through the supported API:
from matplotlib import colormaps
cmap = colormaps.get_cmap(name)
Suggested resolution
Would it be possible to:
- Remove the unused
get_cmap import or replace it with the supported API;
- Add a test that imports SUITPy using the latest supported Matplotlib version; and
- Publish the fix in a patch release?
Thank you for maintaining SUITPy.
Description
SUITPy 2.1.1 cannot be imported when used with Matplotlib 3.11.
SUITPy currently declares the following dependency in
setup.py:Therefore, pip may install Matplotlib 3.11. However,
SUITPy/flatmap.pystill importsget_cmapfrommatplotlib.cm:matplotlib.cm.get_cmapwas removed in Matplotlib 3.11, causingimport SUITPyto fail.Environment
Steps to reproduce
Install the affected versions:
Then try to import SUITPy:
python -c "import SUITPy"Actual behavior
The import fails with:
This prevents all SUITPy functionality from being used, even when the flatmap plotting functions are not needed.
Expected behavior
import SUITPyshould succeed with dependency versions permitted by SUITPy's package metadata.If Matplotlib 3.11 is not yet supported, the dependency metadata could temporarily specify:
Cause
Matplotlib 3.11 removed
matplotlib.cm.get_cmap. The recommended alternatives arematplotlib.colormaps.get_cmapandmatplotlib.pyplot.get_cmap.Matplotlib documents this removal here:
https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.11.0.html#matplotlib-cm-get-cmap
Possible fix
In the current
flatmap.py, the importedget_cmapappears to be unused. Colormap lookup is already performed through:Therefore, the import could likely be changed from:
to:
If
get_cmapis required elsewhere in the future, it could instead be obtained through the supported API:Suggested resolution
Would it be possible to:
get_cmapimport or replace it with the supported API;Thank you for maintaining SUITPy.