Repository navigation
Conversation
matplotlib 3.11 removed matplotlib.cm.get_cmap. The fallback, matplotlib.colormaps[...], raises KeyError or TypeError rather than the ValueError tp relies on to treat an argument as a colour, list or dict, and it rejects Colormap objects. So every non-colourmap colour argument failed, and add_dos, add_ztdiff, add_pfdiff and `tp plot phonons` with a single band.yaml failed even with default arguments. Use matplotlib.pyplot.get_cmap, one of the replacements named in the deprecation warning. It behaves as cm.get_cmap did: Colormap objects are returned unchanged and anything that is not a colourmap raises ValueError. Add tests for each colour form.
A single colour string gave a one-element colour list, so plotting any dataset after the first raised IndexError, on every matplotlib version. Repeat the colour for every dataset.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #117.
matplotlib 3.11 removed
matplotlib.cm.get_cmap. The existing fallback,matplotlib.colormaps[...], raisesKeyError/TypeErrorrather than theValueErrortp uses to fall back to colours, lists and dicts, and it rejects Colormap objects. So on matplotlib >= 3.11 every non-colourmap colour argument fails, and some default calls fail outright:add_dos(ax, data),add_ztdiff,add_pfdiffandtp plot phonons <single band.yaml>.Changes
tp/plot/andtp/cli/cli.py) tomatplotlib.pyplot.get_cmap, one of the replacements named in the deprecation warning. It behaves exactly ascm.get_cmapdid: Colormap objects are returned unchanged, and anything that isn't a colourmap raisesValueError, so the existing fallback code is untouched.LinearSegmentedColormapandListedColormapobjects,'skelton', single colour, list, dict) toadd_multi,add_wideband,add_heatmap,add_waterfallandadd_dos. 31 of them fail without the fix on matplotlib 3.11.test_heatmap.py::HeatmapTest.test_colourmapused the sameget_cmap/colormapsfallback to build its input; it now usesplt.get_cmap, which also removes the deprecation warning in the test log.add_multi(colour='<single colour>'), which raisedIndexErrorfor the second dataset on every matplotlib version.Testing
tests/test_plotpasses fully. The remaining failures in the full suite are unrelated and also fail onmaster:BEOccupationTestunder numpy 2.5, and missing data files intests/test_data/real_data_test.py.python -m unittest): all 175 tests pass.tp plot phononswith one and twoband.yamlfiles, with and without-c, works.CI only runs Python 3.10, so it can't show the fix on matplotlib 3.11; see #118 for a proposal to test more Python versions.