DOC: Switch to OO code style & ensure fixed y-range in `psd_demo3` #6841

Merged
merged 2 commits into from Jul 28, 2016

Conversation

Projects
None yet
5 participants
Contributor

afvincent commented Jul 26, 2016

In psd_demo3.py pylab example:

  • adopt OO code style;
  • fix the y-range to avoid discrepancies between the two subplots in the case of y-values in the 1st subplot that exceed the provided y-tick range (due to an “unfortunate” random draw) .
@afvincent afvincent Switch to OO code style & ensure y-range
382b319

mdboom added the needs_review label Jul 26, 2016

Owner

efiring commented Jul 26, 2016

All examples such as this one that use random data should first call np.random.seed(1) (or some unsigned integer value) so that the data will be repeatable.

@afvincent afvincent Use a RandomState instance with a fixed seed
be8e253
Contributor

afvincent commented Jul 26, 2016

@efiring I agree with you: the example now uses a dedicated RandomState instance as prng. I think this approach is still readable (np.random becoming simply prng here) and it avoids messing with the default prng np.random.

It is part of my plans to try to introduce this kind of reproducible (pseudo-)random draws in the relevant mpl examples (but I do not really have the bandwidth currently…)

@tacaswell tacaswell merged commit 58a4173 into matplotlib:master Jul 28, 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 70.347%
Details

tacaswell removed the needs_review label Jul 28, 2016

@tacaswell tacaswell added a commit that referenced this pull request Jul 28, 2016

@tacaswell tacaswell Merge pull request #6841 from afvincent/fix_psd_demo3
DOC: Switch to OO code style & ensure fixed y-range in `psd_demo3`
a5fe337
Owner

tacaswell commented Jul 28, 2016

backported to v2.x as a5fe337

afvincent deleted the afvincent:fix_psd_demo3 branch Jul 28, 2016

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