Use rounding instead of truncation to calculate the frame size#8250
Closed
ngoldbaum wants to merge 1 commit intomatplotlib:masterfrom
Closed
Use rounding instead of truncation to calculate the frame size#8250ngoldbaum wants to merge 1 commit intomatplotlib:masterfrom
ngoldbaum wants to merge 1 commit intomatplotlib:masterfrom
Conversation
dopplershift
requested changes
Mar 9, 2017
| 'A tuple (width,height) in pixels of a movie frame.' | ||
| w, h = self.fig.get_size_inches() | ||
| return int(w * self.dpi), int(h * self.dpi) | ||
| return round(w * self.dpi), round(h * self.dpi) |
Contributor
There was a problem hiding this comment.
Can you use np.round? Otherwise, the behavior is Python version-dependent.
Member
There was a problem hiding this comment.
For clarity to Nathan, you mean np.round([w * self.dpi, h * self.dpi]), right?
Member
There was a problem hiding this comment.
(tuple of numpy scalars vs numpy array)
Member
There was a problem hiding this comment.
The result (according to the docstring) should still be a tuple.
Contributor
Author
|
Apologies for the noise, this isn't actually right - I get this out the other end: (which is among the weirdest results of a bug I've run into in a while). Will try to dig in and figure out what the real fix is.... |
Contributor
Author
|
I have an alternate fix for this that I will open another pull request for |
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.
This fixes an issue I ran into where the frame sizes were supposed to be adjusted to integers by
_adjust_frame_size, but because theframe_sizeproperty uses truncation, the vagaries of floating point math means that the frame size adjustment didn't work. Here's a snippet from my debugging session that illustrates the issue:I think it's safe just to use rounding here instead of truncation? Maybe we need to add epsilon somewhere instead if this could cause issues.
Yay floating point math!