numpy-legacy-random (NPY002)
Added in v0.0.248 · Related issues · View source
What it does
Checks for the use of legacy np.random function calls.
Why is this bad?
According to the NumPy documentation's Legacy Random Generation:
The
RandomStateprovides access to legacy generators... This class should only be used if it is essential to have randoms that are identical to what would have been produced by previous versions of NumPy.
The members exposed directly on the random module are convenience
functions that alias to methods on a global singleton RandomState
instance. NumPy recommends using a dedicated Generator instance
rather than the random variate generation methods exposed directly on
the random module, as the new Generator is both faster and has
better statistical properties.
See the documentation on Random Sampling and NEP 19 for further details.
Example
Use instead: