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

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

Closed

Conversation

ngoldbaum
Copy link
Contributor

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:

(Pdb) self.fig.get_size_inches()[1]*self.dpi919.99999999999989

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!

@@ -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)
Copy link
Contributor

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.

NelleV reacted with thumbs up emoji
Copy link
Member

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?

Copy link
Member

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)

Copy link
Member

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.

@ngoldbaum
Copy link
ContributorAuthor

Apologies for the noise, this isn't actually right - I get this out the other end:

http://imgur.com/a/SWcPI

(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....

afvincent reacted with laugh emoji

@ngoldbaum
Copy link
ContributorAuthor

I have an alternate fix for this that I will open another pull request for

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@QuLogicQuLogicQuLogic left review comments

@phobsonphobsonphobson left review comments

@dopplershiftdopplershiftdopplershift requested changes

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@ngoldbaum@dopplershift@QuLogic@phobson

[8]ページ先頭

©2009-2025 Movatter.jp