ENH examples are now reproducible #7386

Merged
merged 2 commits into from Nov 3, 2016

Conversation

Projects
None yet
5 participants
Contributor

NelleV commented Nov 3, 2016

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

supersedes #7382

NelleV changed the title from ENH examples are now reproducible to [MRG] ENH examples are now reproducible Nov 3, 2016

Member

story645 commented Nov 3, 2016

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

Contributor

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

@NelleV NelleV ENH examples are now reproducible
- added a random seed in every single example that needed one.
b90cd59
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.

Contributor

NelleV commented Nov 3, 2016

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

@@ -7,6 +7,10 @@
from matplotlib.collections import EventCollection
import numpy as np
+# Fixing random state for reproducibility
+np.random.seed(19680801)
@QuLogic

QuLogic Nov 3, 2016

Member

This one already has a seed.

@NelleV NelleV MAINT seed need to be fixed only once
2c08c49
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).

Contributor

NelleV commented Nov 3, 2016

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

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 added this to the 2.1 (next point release) milestone Nov 3, 2016

Member

QuLogic commented Nov 3, 2016

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

Contributor

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

@ivanov

ivanov approved these changes Nov 3, 2016

Looks good to me, thanks, @NelleV !

ivanov changed the title from [MRG] ENH examples are now reproducible to [MRG+1] ENH examples are now reproducible Nov 3, 2016

@tacaswell tacaswell merged commit dbf9c44 into matplotlib:master Nov 3, 2016

3 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 61.84%
Details
Owner

tacaswell commented Nov 3, 2016

👍 I like the choice of the seed.

QuLogic changed the title from [MRG+1] ENH examples are now reproducible to ENH examples are now reproducible Nov 5, 2016

lesteve referenced this pull request in sphinx-gallery/sphinx-gallery Nov 9, 2016

Closed

Wish: option for boilerplate code to execute before a plot #158

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