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

Appearance settings

Updating animation file writer to allow keywork arguments when using with construct #6304

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 29, 2016

Conversation

jmc734
Copy link
Contributor

@jmc734 jmc734 commented Apr 14, 2016

Previously, in order to pass configurations to saving() and subsequently setup(), the caller had to provide positional arguments. There is nothing explicitly wrong with that approach though the saving() method is currently advertised as taking the same parameters as setup(). For example, if you wanted to disable temporary file clearing for a FileMovieWriter, you previously would not have been able to structure it like this:

with recorder.saving(fig, capFile, capDPI, tempPrefix, clear_temp = False):

Instead, you would have to know the order of the arguments and make the call like so:

with recorder.saving(fig, capFile, capDPI, tempPrefix, False):

This is a small change but I think it makes code easier to read and more tolerant to future API change.

@@ -246,7 +246,7 @@ def frame_size(self):
width_inches, height_inches = self.fig.get_size_inches()
return width_inches * self.dpi, height_inches * self.dpi

def setup(self, fig, outfile, dpi, *args):
def setup(self, fig, outfile, dpi, *args, **kwargs):
Copy link
Member

Choose a reason for hiding this comment

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

can you remove both args and kwargs from this signature? We do not use either of them so having them will just mask errors.

Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't removing *args be a potential compatibility break? Admittedly, I am having a hard time imagining a scenario where one would have had extra arguments down to this point, but I just wanted to make sure we aren't doing something blindly. It would be nice if I could remember why we had *args there in the first place...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was added way back in 2012 in the original work-in-progress commit for animation file writers. Unfortunately, that commit has no further documentation other than the code changes themselves. I would venture a guess though that the reasoning was that saving() took arbitrary arguments and called setup() with them so, if for some reason an overriden setup() called the super setup() with the entire set of arbitrary arguments, it wouldn't break. If that is true then I think we should remove it as that case is unlikely and would be kind of dirty anyway.

@dopplershift
Copy link
Contributor

Other than @tacaswell 's comment, it's a 👍 from me.

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Apr 29, 2016
@tacaswell tacaswell merged commit 6bac790 into matplotlib:master Apr 29, 2016
@tacaswell
Copy link
Member

Thanks!

@jmc734 I think this is your first contribution to mpl. Congratulations and hopefully we will see you again 🎉 .

@efiring
Copy link
Member

efiring commented Sep 28, 2016

@tacaswell, may I backport this? I view it as fixing a rather frustrating bug, which I tripped over and reported in #7191.

efiring added a commit to efiring/matplotlib that referenced this pull request Sep 30, 2016
This is the functionality added to master in 6bac790 (matplotlib#6304).
Directly cherry-picking that is not possible because of the intervening
introduction of abstract base classes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.