8000 Fix matplotlib v3.9 colormaps by dagewa · Pull Request #2688 · dials/dials · GitHub
[go: up one dir, main page]

Skip to content

Fix matplotlib v3.9 colormaps #2688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 7, 2024
Merged

Fix matplotlib v3.9 colormaps #2688

merged 6 commits into from
Aug 7, 2024

Conversation

dagewa
Copy link
Member
@dagewa dagewa commented Jul 2, 2024

Change previously deprecated matplotlib.cm.get_cmap(cmap) calls to matplotlib.colormaps[cmap]

@Baharis
Copy link
Contributor
Baharis commented Jul 2, 2024

Relevant cctbx PR: cctbx/cctbx_project#894. It's 2 am at the west coast right now so I might be wrong, but IIRC I finally settled on the other accessor as syntax matplotlib.colormaps[cmap] is absent in old-ish versions of mpl.

@dagewa
Copy link
Member Author
dagewa commented Jul 2, 2024

Ah, thanks

@dagewa
Copy link
Member Author
dagewa commented Jul 2, 2024

Looks like plt.get_cmp was kept because it is "too widely used to be removed" matplotlib/matplotlib#20853. That implies removal was considered. I'll stick with the matplotlib.colormaps[cmap] version for DIALS as I don't think we are aiming to support older matplotlibs.

Copy link
codecov bot commented Jul 2, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 78.15%. Comparing base (769dab7) to head (d9a9f43).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2688      +/-   ##
==========================================
- Coverage   78.15%   78.15%   -0.01%     
==========================================
  Files         616      616              
  Lines       76589    76588       -1     
  Branches    10980    10980              
==========================================
- Hits        59858    59855       -3     
- Misses      14491    14492       +1     
- Partials     2240     2241       +1     

@Baharis
Copy link
Contributor
Baharis commented Jul 2, 2024

@dagewa I share your sentiment and, personally, dislike the need to support old installations (cctbx being an extreme case of sticking to Python 2); I just say that because I feel the need to note that in case someone is working on a late 2021 / early 2022 installation and updates codebase only (or some other stuff that people do), this will break their code since this syntax was introduced in November 2021. Other than that I am all in and happy for you that you can use this new smooth syntax :).

@dagewa dagewa merged commit 32ad28b into main Aug 7, 2024
18 checks passed
@dagewa dagewa deleted the fix-matplotlib-colormaps branch August 7, 2024 13:10
graeme-winter pushed a commit that referenced this pull request Nov 19, 2024
Fix for "matplotlib.cm has no attribute get_cmap"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0