8000 Remove matplotlib cache manipulation by ksunden · Pull Request #3332 · mwaskom/seaborn · GitHub
[go: up one dir, main page]

Skip to content

Remove matplotlib cache manipulation #3332

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 1 commit into from
May 4, 2023

Conversation

ksunden
Copy link
Contributor
@ksunden ksunden commented Apr 19, 2023

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.

@codecov
Copy link
codecov bot commented Apr 23, 2023

Codecov Report

Merging #3332 (d865626) into master (4f72554) will increase coverage by 0.00%.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #3332   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files          77       77           
  Lines       24942    24952   +10     
=======================================
+ Hits        24538    24548   +10     
  Misses        404      404           
Impacted Files Coverage Δ
seaborn/_core/plot.py 99.38% <ø> (-0.01%) ⬇️
seaborn/palettes.py 99.59% <ø> (-0.01%) ⬇️

... and 3 files with indirect coverage changes

@mwaskom
Copy link
Owner
mwaskom commented May 4, 2023

Thanks @ksunden

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0