[SciPy-Dev] RNG and examples

Pamphile Roy roy.pamphile at gmail.com
Sun Apr 18 16:51:52 EDT 2021


Hi everyone,

We just merged a PR about using RNG in examples.

From now one, please only use the new NumPy np.random.Generator API and don’t explicitly seed (either the generator or globally).
This is the new canonical way:

>>> rng = np.random.default_rng()
>>> sample = rng.random(...)

The first line is initializing the generator, BUT, it will get overridden to add a seed. So the examples are still deterministic.

We are doing all this to promote good practices among users.
It’s very important to use the new NumPy API and to use sensible seeding only when appropriate (testing for instance).

For more discussions, please see the PR: https://github.com/scipy/scipy/pull/13863 <https://github.com/scipy/scipy/pull/13863>

Thanks everyone.

Cheers,
Pamphile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scipy-dev/attachments/20210418/5c080412/attachment.html>


More information about the SciPy-Dev mailing list