Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Use rounding instead of truncation to calculate the frame size#8250
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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
@@ -267,7 +267,7 @@ def __init__(self, fps=5, codec=None, bitrate=None, extra_args=None, | |||
def frame_size(self): | |||
'A tuple (width,height) in pixels of a movie frame.' | |||
w, h = self.fig.get_size_inches() | |||
returnint(w * self.dpi),int(h * self.dpi) | |||
returnround(w * self.dpi),round(h * self.dpi) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Can you usenp.round
? Otherwise, the behavior is Python version-dependent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
For clarity to Nathan, you meannp.round([w * self.dpi, h * self.dpi])
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
(tuple of numpy scalars vs numpy array)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
The result (according to the docstring) should still be a tuple.
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.... |
I have an alternate fix for this that I will open another pull request for |
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_size
property 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!