Remove matplotlib cache manipulation #3332
Merged
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.
The
colorConverter.cache
manipulation is not actually doing what appears to be expected.Since mpl 2.0 (matplotlib/matplotlib#6382), whenever
colorConverter.colors
is updated,colorConverter.cache
is emptied.Thus in each location where it is accessed within seaborn, only the last element (
"k"
) actually survives in the cache at all.Additionally, internal matplotlib usage uses the
("color", alpha)
tuple as the cache keys rather than just the"color"
, so I don't think that"k"
will ever be looked up by mpl code even though it is in the cache.As such, I thought the simplest solution was to simply remove the cache manipulation entirely, since it has no ill effect, and the cache of old values is correctly invalidated regardless.
This was found as I have been running type checkers over some of our (matplotlib's) dependencies after matplotlib/matplotlib#24976.
I had typed the cache as having the tuple form as keys after inspecting internal usage, and that was flagged when I type checked over here.
There are still type checking errors that likely need to be addressed (some on our end which I either have submitted PRs or plan to fix before the release of mpl v3.8 in a couple months)
There remains some need of ensuring seaborn's type hints are consistent with matplotlibs that may incur a mix of changes on either end, feel free to ping me if you have any questions regarding mpl's type hints, happy to help sort out any errors that are spotted.
I did want to make sure you were aware of this change prior to the mpl release to mitigate chances of our release e.g. failing your CI because of type hints being added.