Skip to content

Commit

Permalink
Move motivation section
Browse files Browse the repository at this point in the history
  • Loading branch information
mdhaber committed Aug 7, 2024
1 parent 37ff883 commit 2dcf128
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions spec-0007/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ We suggest implementing these principles by:
Note that `numpy.random.default_rng` does not accept instances of `RandomState`, so user control of library behavior with instances of `RandomState` is effectively deprecated, too.
That said, neither `np.random.seed` nor `np.random.RandomState` themselves are deprecated, so they may still be used in some contexts (e.g. by developers for generating unit test data).

## Motivation

Two strong motivations for moving over to `Generator`s are:

1. they avoid naïve seeding strategies, such as using successive integers, via the underlying [SeedSequence](https://numpy.org/doc/stable/reference/random/parallel.html#seedsequence-spawning);
2. they avoid using global state (from `numpy.random.mtrand._rand`).

### Scope

This is intended as a recommendation to all libraries that allow users to control the
Expand All @@ -56,11 +63,6 @@ In practice, the seed is unfortunately also often controlled using `numpy.random

Legacy behavior in packages such as scikit-learn (`sklearn.utils.check_random_state`) typically handle `None` (use the global seed state), an int (convert to `RandomState`), or `RandomState` object.

Two strong motivations for moving over to `Generator`s are:

1. they avoid naïve seeding strategies, such as using successive integers, via the underlying [SeedSequence](https://numpy.org/doc/stable/reference/random/parallel.html#seedsequence-spawning);
2. they avoid using global state (from `numpy.random.mtrand._rand`).

Our recommendation here is a deprecation strategy which does not in _all_ cases adhere to the Hinsen principle[^hinsen],
although it could very nearly do so by enforcing the use of `rng` as a keyword argument.

Expand Down

0 comments on commit 2dcf128

Please sign in to comment.