Open
Description
numpy
has gone away from the np.random.seed
/np.random.set_state
/np.random.get_state
models for random number generation. astropy
should follow suit where possible. This in practice means the following tasks:
- Stop using our home-grown
RNGContext
in the tests and replace with the newernumpy
mechanism. - Replace anywhere that
np.random.*
is used currently with something that uses the new mechanism (e.g. the random functions in Add new module for generating random or gridded spherical points #11628 ), which may require some API additions to let the new numpy generators be passed into functions. - ? Deprecate our home-grown
RNGContext
and replacing it with the "new" numpy mechanism. Note it is not currently clear to me if we can do this. I don't think the numpy scheme supports a context manager a la ourScienceState
approach. In that case we have to decide if we think it's worth supporting this long-term, trying to get this intonumpy
or just deciding it's better to use thenumpy
approach anyway.
For some backstory/justification on the numpy
shift see:
- https://numpy.org/doc/stable/reference/random/index.html - the paragraph beginning with "Since Numpy version 1.17.0"
- https://numpy.org/doc/stable/reference/random/new-or-different.html#new-or-different
- https://towardsdatascience.com/stop-using-numpy-random-seed-581a9972805f