scipy
scipy copied to clipboard
BUG: copied/pickled dists lose connection to RandomState
This is a possible fix for issue #16998 -- assuming I correctly interpreted it as a bug / undesirable behaviour.
After this, distributions initialized without a custom random state will couple to numpy's global random state, even after an unpickle or deepcopy. Nothing changes for distributions that have custom random states/seeds set.
Implementation details:
- The
_random_state
attribute of distributions can now beNone
, signifying compliance with the global random state. Therandom_state
property converts thisNone
into the current numpyRandomState
when needed. - Replaced
self._random_state
withself.random_state
in a few methods that probably predate #4340 - Added tests for regular and frozen distributions. We still test that explicitly-set random states are copied (as before).
Nothing changes for existing pickles of distributions either. We could not change that even if we wanted to: those pickles contain RandomStates in their attributes, without a way to tell whether those were intentionally specified or not.
(The linux/mac meson build failures mirror those on the current master)