Movatterモバイル変換


[0]ホーム

URL:


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

FIX: ignore non-finite bbox#12651

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedOct 27, 2018
edited
Loading

PR Summary

closes#12648

deftest_gettightbbox_ignoreNaN():fig,ax=plt.subplots()t=ax.text(np.NaN,1,'Boo')renderer=fig.canvas.get_renderer()np.testing.assert_allclose(ax.get_tightbbox(renderer).width,532.13194)

Previously,ax.get_tightbbox would find a non-finite bbox because text's bbox was not defined. This ignores such bbox's when getting the axes bbox.

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymakjklymak added the topic: geometry managerLayoutEngine, Constrained layout, Tight layout labelOct 27, 2018
@Tillsten
Copy link
Contributor

Why not letget_tightbox return None instead working around the non-finite bbox?

@jklymak
Copy link
MemberAuthor

@Tillsten you meanget_tightbbox of the axes children? I think thats a good idea as well, but I wasn't sure I'd be able to squash all possibleget_tightbbox implementations.

I think I'll do that for the baseArtist.get_tightbbox, but maybe keep this check too in case someone has done something special.

@jklymakjklymakforce-pushed thefix-ignore-non-finite-bbox branch fromb8ba0c0 to927b7c6CompareOctober 27, 2018 20:50
@jklymak
Copy link
MemberAuthor

@Tillsten added the check in both places now. The one inAxes._get_tightbbox can't hurt (except maybe the eyes for the long if-statement).

@jklymakjklymakforce-pushed thefix-ignore-non-finite-bbox branch from927b7c6 to07ac112CompareOctober 28, 2018 02:34
@jklymakjklymak added this to thev3.0.x milestoneOct 28, 2018
timhoffm
timhoffm previously requested changesOct 28, 2018
Copy link
Member

@timhoffmtimhoffm left a comment

Choose a reason for hiding this comment

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

ReturningNone instead of an infiniteBBox is an API change. I'm -1 on that as I don't see any benefit. In contrast, it obscures information. An infiniteBBox is a defined object. You can e.g. still find out if the width or height is infinite.

@jklymak
Copy link
MemberAuthor

jklymak commentedOct 28, 2018
edited by timhoffm
Loading

Yeah I’m flexible about that. The original PR didn’t have this - it just checked for finite bbox widths and heights.

OTOH it’s not necessarily a bad idea to invalidate things we know we can’t do anything with. A NaN bbox width is not going to mean anything and pushing all the checks to a higher level just means more checks at a higher level.

@timhoffm
Copy link
Member

timhoffm commentedOct 28, 2018
edited
Loading

A NaN bbox width is not going to mean anything and pushing all the checks to a higher level just means more checks at a higher level.

You'll have a newbbox is None check to do anyway at the higher level. If desired you could alternatively add anis_finite() method and checkbbox.is_finite(). (Or maybeis_valid() - Qt uses this naming convention.)

Edit: Would need careful consideration on the actual naming of such a method.

@jklymak
Copy link
MemberAuthor

Right but we already check for None. Not sure why, though.

@jklymakjklymakforce-pushed thefix-ignore-non-finite-bbox branch from07ac112 tod2523e0CompareOctober 29, 2018 16:31
@jklymakjklymakforce-pushed thefix-ignore-non-finite-bbox branch fromd2523e0 to49570b4CompareOctober 29, 2018 16:32
@jklymak
Copy link
MemberAuthor

Removedartist.get_tightbbox returningNone if non-finite bbox.

@tacaswelltacaswell dismissedtimhoffm’sstale reviewOctober 29, 2018 19:34

Has been addressed and API is not changed.

@anntzeranntzer merged commit41f72fb intomatplotlib:masterOct 29, 2018
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestOct 29, 2018
@jklymakjklymak deleted the fix-ignore-non-finite-bbox branchOctober 29, 2018 19:37
jklymak added a commit that referenced this pull requestOct 29, 2018
…651-on-v3.0.xBackport PR#12651 on branch v3.0.x (FIX: ignore non-finite bbox)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@anntzeranntzeranntzer approved these changes

@timhoffmtimhoffmtimhoffm left review comments

Assignees
No one assigned
Labels
topic: geometry managerLayoutEngine, Constrained layout, Tight layout
Projects
None yet
Milestone
v3.0.2
Development

Successfully merging this pull request may close these issues.

Regression when calling annotate with nan values for the position
5 participants
@jklymak@Tillsten@timhoffm@tacaswell@anntzer

[8]ページ先頭

©2009-2025 Movatter.jp