Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make sure SubFigure has _cachedRenderer #23174

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
tacaswell merged 1 commit into matplotlib:main from oscargus:clabelsubfigures
Jun 2, 2022

Conversation

Copy link
Member

@oscargus oscargus commented Jun 1, 2022
edited
Loading

PR Summary

Makes sure that _cachedRenderer is added to SubFigure instances by moving it to FigureBase. Closes #23173

Maybe the code in contour should behave differently, but I assume that sooner or later the same problem may happen in other code when applied to a SubFigure and not a Figure.

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@oscargus oscargus changed the title (削除) Make sure SubFigure have _cachedRenderer (削除ここまで) (追記) Make sure SubFigure has _cachedRenderer (追記ここまで) Jun 1, 2022
Copy link
Member

jklymak commented Jun 1, 2022

I'm not sure this is the correct fix? The renderer for the subfigure should be the same as the parent's renderer. I think we need to set this up as a property and have the getter go up the tree to the parent?

Copy link
Member Author

oscargus commented Jun 1, 2022

I'm not sure this is the correct fix?

No idea. What you says make sense though, so I'll give it a go.

Copy link
Member Author

oscargus commented Jun 1, 2022

On draw SubFigure redefines the _cachedRenderer. Will there ever be cases where it differs from the parent renderer?

Copy link
Member Author

oscargus commented Jun 1, 2022

Updated with properties. Not convinced that one need to set the renderer in draw, but guess it shouldn't hurt?

Copy link
Member

jklymak commented Jun 1, 2022

The subfigure really should not have a cached renderer, but subfigures have been abstracted to be like figures so that child artists don't know if they are in a figure or a subfigure. So if an artist does self.figure._cachedRenderer that should always point to the top-most renderer.

Copy link
Member

jklymak commented Jun 1, 2022

I think this is correct. Note that #22745 would have fixed this as well by calling figure._get_renderer().

Copy link
Member Author

oscargus commented Jun 1, 2022

Note that #22745 would have fixed this as well by calling figure._get_renderer().

Ahh, OK! Maybe better to try to get that in then? I have not really followed (nor fully understand) that discussion.

I guess that the test added here very well can be worthwhile keeping as it seems to exercise the code in a way that once was (currently is) broken.

Copy link
Member

jklymak commented Jun 1, 2022

I think we can have both fixes. #22745 isn't necessarily going to go in ;-)

@tacaswell tacaswell added this to the v3.5.3 milestone Jun 1, 2022
Copy link
Member

I suspect this is an argument as to why we actually do need to cache the renderer (and should move it to a central canonical place) and my position that we should not cache it at all is wrong (or at least currently infeasible).

Copy link
Member

@tacaswell tacaswell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Anyone can merge on green.

Copy link
Member

I restarted the failed windows job (it was a blit test in a subprocess I have not seen fail before 🤞🏻 it is transient).

@tacaswell tacaswell merged commit af83578 into matplotlib:main Jun 2, 2022
Copy link

lumberbot-app bot commented Jun 2, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.5.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 af835787ac405d6021d4ed11e57734873c401b9c
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #23174: Make sure SubFigure has _cachedRenderer'
  1. Push to a named branch:
git push YOURFORK v3.5.x:auto-backport-of-pr-23174-on-v3.5.x
  1. Create a PR against branch v3.5.x, I would have named this PR:

"Backport PR #23174 on branch v3.5.x (Make sure SubFigure has _cachedRenderer)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Jun 2, 2022
Merge pull request matplotlib#23174 from oscargus/clabelsubfigures
FIX: Make sure SubFigure has _cachedRenderer
(cherry picked from commit af83578)
timhoffm added a commit that referenced this pull request Jun 4, 2022
...-v3.5.x
Backport PR #23174: Make sure SubFigure has _cachedRenderer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@tacaswell tacaswell tacaswell approved these changes

@jklymak jklymak jklymak approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.5.3
Development

Successfully merging this pull request may close these issues.

[Bug]: Crash when adding clabels to subfigures

AltStyle によって変換されたページ (->オリジナル) /