X Tutup
Skip to content

ENH examples are now reproducible#7386

Merged
tacaswell merged 2 commits intomatplotlib:masterfrom
NelleV:numpy_seed
Nov 3, 2016
Merged

ENH examples are now reproducible#7386
tacaswell merged 2 commits intomatplotlib:masterfrom
NelleV:numpy_seed

Conversation

@NelleV
Copy link
Copy Markdown
Member

@NelleV NelleV commented Nov 3, 2016

  • added a random seed in every single example that needed one.

supersedes #7382

@NelleV NelleV changed the title ENH examples are now reproducible [MRG] ENH examples are now reproducible Nov 3, 2016
@story645
Copy link
Copy Markdown
Member

story645 commented Nov 3, 2016

LGTM but super curious if you did this manually or with a script.

@NelleV
Copy link
Copy Markdown
Member Author

NelleV commented Nov 3, 2016

I git grepped to find which examples needed it and did it manually. With vim it was quite straightforward and reasonable fast (~20minutes).

- added a random seed in every single example that needed one.
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Nov 3, 2016

The code added after functions is one line too high; should be two blank lines after the function and one after the new code, but it's the other way around.

@NelleV
Copy link
Copy Markdown
Member Author

NelleV commented Nov 3, 2016

@QuLogic I am not sure what you mean by this. pep8 is happy.

import numpy as np

# Fixing random state for reproducibility
np.random.seed(19680801)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one already has a seed.

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Nov 3, 2016

Maybe pep8 became less strict about it, or maybe it only requires two blank lines before the function? I prefer to also use two blank lines after (at least for top-level functions).

@NelleV
Copy link
Copy Markdown
Member Author

NelleV commented Nov 3, 2016

It only requires two blank lines before a function. It has never required blank lines after.

@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Nov 3, 2016

The seed is, in many places, one blank line away from the function and two blank lines away from the code. This makes it "seem" more related to the function when it's not. So the single blank line after the function is not bad; it's just the implication when coupled with the two blank lines below the seeding.

@QuLogic QuLogic added this to the 2.1 (next point release) milestone Nov 3, 2016
@QuLogic
Copy link
Copy Markdown
Member

QuLogic commented Nov 3, 2016

I think @ivanov noted some other files in doc/pyplots that need this as well.

@NelleV
Copy link
Copy Markdown
Member Author

NelleV commented Nov 3, 2016

I'll do another PR for those, as they shouldn't be in that folder (it predates the gallery generation scripts).

Copy link
Copy Markdown
Member

@ivanov ivanov left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks, @NelleV !

@ivanov ivanov changed the title [MRG] ENH examples are now reproducible [MRG+1] ENH examples are now reproducible Nov 3, 2016
@tacaswell tacaswell merged commit dbf9c44 into matplotlib:master Nov 3, 2016
@tacaswell
Copy link
Copy Markdown
Member

👍 I like the choice of the seed.

@QuLogic QuLogic changed the title [MRG+1] ENH examples are now reproducible ENH examples are now reproducible Nov 5, 2016
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.

5 participants

X Tutup