Simplify check for tight-bbox finiteness.#13427
Merged
Merged
Conversation
anntzer
commented
Feb 13, 2019
|
|
||
| for a in [self.label, self.offsetText]: | ||
| bbox = a.get_window_extent(renderer) | ||
| if (np.isfinite(bbox.width) and np.isfinite(bbox.height) and |
Contributor
Author
There was a problem hiding this comment.
this finiteness check is redundant with the one below
timhoffm
previously approved these changes
Feb 13, 2019
| if (bbox is not None and | ||
| (bbox.width != 0 or bbox.height != 0) and | ||
| np.isfinite(bbox.width) and np.isfinite(bbox.height)): | ||
| 0 < bbox.width < np.inf and 0 < bbox.height < np.inf): |
Member
There was a problem hiding this comment.
Optional, but might be easier to read when wrapping the height check to a separate line.
| @@ -1152,20 +1152,15 @@ def get_tightbbox(self, renderer): | |||
| self.offsetText.set_text(self.major.formatter.get_offset()) | |||
|
|
|||
| bb = [] | |||
Member
There was a problem hiding this comment.
While we're at it, could be renamed to bboxes. Optional.
Contributor
Author
|
both comments handled |
Member
|
Is it worth doing |
Member
|
The values can be See #13426 |
Contributor
Author
|
But... that's the point here: these are places that check |
`0 < bbox.width < np.inf` is as explicit as `bbox.width != 0 and np.isfinite(bbox.width)`, shorter, and faster (not that it is a bottleneck, though). (It works because bboxes are oriented to have nonnegative widths and heights.)
Member
|
🐑 Sorry, was sleepy and got confused about the polarity we were looking at here. |
timhoffm
approved these changes
Feb 14, 2019
Member
|
Thanks @anntzer |
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.
0 < bbox.width < np.infis as explicit asbbox.width != 0 and np.isfinite(bbox.width), shorter, and faster (not that it is abottleneck, though). (It works because bboxes are oriented to have
nonnegative widths and heights.)
PR Summary
PR Checklist