Fix import failure on matplotlib 3.11#727
Merged
Merged
Conversation
matplotlib 3.11 no longer auto-imports matplotlib.style.core, so style.core.USER_LIBRARY_PATHS raised AttributeError at import time. Use the top-level style.USER_LIBRARY_PATHS when present, fall back to style.core for older matplotlib, and call style.reload_library(). Closes arviz-devs#726
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #727 +/- ##
==========================================
- Coverage 82.16% 82.15% -0.01%
==========================================
Files 112 112
Lines 10641 10643 +2
==========================================
+ Hits 8743 8744 +1
- Misses 1898 1899 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
thanks @anevolbap |
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.
Description
matplotlib 3.11 no longer auto-imports the
matplotlib.style.coresubmodule, so thestyle.core.USER_LIBRARY_PATHS.append(...)call inpreliz/__init__.pyraisesAttributeErrorat import time. This uses the top-levelstyle.USER_LIBRARY_PATHSwhen it exists, falls back tostyle.corefor older matplotlib, and callsstyle.reload_library()(present on all supported versions).Checked across matplotlib 3.9, 3.10, and 3.11:
style.USER_LIBRARY_PATHSexists only on 3.11,style.coreexists on 3.9 and 3.10, andstyle.reload_libraryexists on all three, so the guard covers the fullmatplotlib>=3.9range.Closes #726.
Checklist