---
source: crates/ruff/src/rules/numpy/mod.rs
---
NPY002.py:10:8: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator`
   |
10 | # instead of this (legacy version)
11 | from numpy import random
12 | vals = random.standard_normal(10)
   |        ^^^^^^^^^^^^^^^^^^^^^^ NPY002
13 | more_vals = random.standard_normal(10)
14 | numbers = random.integers(high, size=5)
   |

NPY002.py:11:13: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator`
   |
11 | from numpy import random
12 | vals = random.standard_normal(10)
13 | more_vals = random.standard_normal(10)
   |             ^^^^^^^^^^^^^^^^^^^^^^ NPY002
14 | numbers = random.integers(high, size=5)
   |

NPY002.py:15:1: NPY002 Replace legacy `np.random.seed` call with `np.random.Generator`
   |
15 | import numpy
16 | numpy.random.seed()
   | ^^^^^^^^^^^^^^^^^ NPY002
17 | numpy.random.get_state()
18 | numpy.random.set_state()
   |

NPY002.py:16:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator`
   |
16 | import numpy
17 | numpy.random.seed()
18 | numpy.random.get_state()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
19 | numpy.random.set_state()
20 | numpy.random.rand()
   |

NPY002.py:17:1: NPY002 Replace legacy `np.random.set_state` call with `np.random.Generator`
   |
17 | numpy.random.seed()
18 | numpy.random.get_state()
19 | numpy.random.set_state()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
20 | numpy.random.rand()
21 | numpy.random.randn()
   |

NPY002.py:18:1: NPY002 Replace legacy `np.random.rand` call with `np.random.Generator`
   |
18 | numpy.random.get_state()
19 | numpy.random.set_state()
20 | numpy.random.rand()
   | ^^^^^^^^^^^^^^^^^ NPY002
21 | numpy.random.randn()
22 | numpy.random.randint()
   |

NPY002.py:19:1: NPY002 Replace legacy `np.random.randn` call with `np.random.Generator`
   |
19 | numpy.random.set_state()
20 | numpy.random.rand()
21 | numpy.random.randn()
   | ^^^^^^^^^^^^^^^^^^ NPY002
22 | numpy.random.randint()
23 | numpy.random.random_integers()
   |

NPY002.py:20:1: NPY002 Replace legacy `np.random.randint` call with `np.random.Generator`
   |
20 | numpy.random.rand()
21 | numpy.random.randn()
22 | numpy.random.randint()
   | ^^^^^^^^^^^^^^^^^^^^ NPY002
23 | numpy.random.random_integers()
24 | numpy.random.random_sample()
   |

NPY002.py:21:1: NPY002 Replace legacy `np.random.random_integers` call with `np.random.Generator`
   |
21 | numpy.random.randn()
22 | numpy.random.randint()
23 | numpy.random.random_integers()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
24 | numpy.random.random_sample()
25 | numpy.random.choice()
   |

NPY002.py:22:1: NPY002 Replace legacy `np.random.random_sample` call with `np.random.Generator`
   |
22 | numpy.random.randint()
23 | numpy.random.random_integers()
24 | numpy.random.random_sample()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
25 | numpy.random.choice()
26 | numpy.random.bytes()
   |

NPY002.py:23:1: NPY002 Replace legacy `np.random.choice` call with `np.random.Generator`
   |
23 | numpy.random.random_integers()
24 | numpy.random.random_sample()
25 | numpy.random.choice()
   | ^^^^^^^^^^^^^^^^^^^ NPY002
26 | numpy.random.bytes()
27 | numpy.random.shuffle()
   |

NPY002.py:24:1: NPY002 Replace legacy `np.random.bytes` call with `np.random.Generator`
   |
24 | numpy.random.random_sample()
25 | numpy.random.choice()
26 | numpy.random.bytes()
   | ^^^^^^^^^^^^^^^^^^ NPY002
27 | numpy.random.shuffle()
28 | numpy.random.permutation()
   |

NPY002.py:25:1: NPY002 Replace legacy `np.random.shuffle` call with `np.random.Generator`
   |
25 | numpy.random.choice()
26 | numpy.random.bytes()
27 | numpy.random.shuffle()
   | ^^^^^^^^^^^^^^^^^^^^ NPY002
28 | numpy.random.permutation()
29 | numpy.random.beta()
   |

NPY002.py:26:1: NPY002 Replace legacy `np.random.permutation` call with `np.random.Generator`
   |
26 | numpy.random.bytes()
27 | numpy.random.shuffle()
28 | numpy.random.permutation()
   | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
29 | numpy.random.beta()
30 | numpy.random.binomial()
   |

NPY002.py:27:1: NPY002 Replace legacy `np.random.beta` call with `np.random.Generator`
   |
27 | numpy.random.shuffle()
28 | numpy.random.permutation()
29 | numpy.random.beta()
   | ^^^^^^^^^^^^^^^^^ NPY002
30 | numpy.random.binomial()
31 | numpy.random.chisquare()
   |

NPY002.py:28:1: NPY002 Replace legacy `np.random.binomial` call with `np.random.Generator`
   |
28 | numpy.random.permutation()
29 | numpy.random.beta()
30 | numpy.random.binomial()
   | ^^^^^^^^^^^^^^^^^^^^^ NPY002
31 | numpy.random.chisquare()
32 | numpy.random.dirichlet()
   |

NPY002.py:29:1: NPY002 Replace legacy `np.random.chisquare` call with `np.random.Generator`
   |
29 | numpy.random.beta()
30 | numpy.random.binomial()
31 | numpy.random.chisquare()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
32 | numpy.random.dirichlet()
33 | numpy.random.exponential()
   |

NPY002.py:30:1: NPY002 Replace legacy `np.random.dirichlet` call with `np.random.Generator`
   |
30 | numpy.random.binomial()
31 | numpy.random.chisquare()
32 | numpy.random.dirichlet()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
33 | numpy.random.exponential()
34 | numpy.random.f()
   |

NPY002.py:31:1: NPY002 Replace legacy `np.random.exponential` call with `np.random.Generator`
   |
31 | numpy.random.chisquare()
32 | numpy.random.dirichlet()
33 | numpy.random.exponential()
   | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
34 | numpy.random.f()
35 | numpy.random.gamma()
   |

NPY002.py:32:1: NPY002 Replace legacy `np.random.f` call with `np.random.Generator`
   |
32 | numpy.random.dirichlet()
33 | numpy.random.exponential()
34 | numpy.random.f()
   | ^^^^^^^^^^^^^^ NPY002
35 | numpy.random.gamma()
36 | numpy.random.geometric()
   |

NPY002.py:33:1: NPY002 Replace legacy `np.random.gamma` call with `np.random.Generator`
   |
33 | numpy.random.exponential()
34 | numpy.random.f()
35 | numpy.random.gamma()
   | ^^^^^^^^^^^^^^^^^^ NPY002
36 | numpy.random.geometric()
37 | numpy.random.get_state()
   |

NPY002.py:34:1: NPY002 Replace legacy `np.random.geometric` call with `np.random.Generator`
   |
34 | numpy.random.f()
35 | numpy.random.gamma()
36 | numpy.random.geometric()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
37 | numpy.random.get_state()
38 | numpy.random.gumbel()
   |

NPY002.py:35:1: NPY002 Replace legacy `np.random.get_state` call with `np.random.Generator`
   |
35 | numpy.random.gamma()
36 | numpy.random.geometric()
37 | numpy.random.get_state()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
38 | numpy.random.gumbel()
39 | numpy.random.hypergeometric()
   |

NPY002.py:36:1: NPY002 Replace legacy `np.random.gumbel` call with `np.random.Generator`
   |
36 | numpy.random.geometric()
37 | numpy.random.get_state()
38 | numpy.random.gumbel()
   | ^^^^^^^^^^^^^^^^^^^ NPY002
39 | numpy.random.hypergeometric()
40 | numpy.random.laplace()
   |

NPY002.py:37:1: NPY002 Replace legacy `np.random.hypergeometric` call with `np.random.Generator`
   |
37 | numpy.random.get_state()
38 | numpy.random.gumbel()
39 | numpy.random.hypergeometric()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
40 | numpy.random.laplace()
41 | numpy.random.logistic()
   |

NPY002.py:38:1: NPY002 Replace legacy `np.random.laplace` call with `np.random.Generator`
   |
38 | numpy.random.gumbel()
39 | numpy.random.hypergeometric()
40 | numpy.random.laplace()
   | ^^^^^^^^^^^^^^^^^^^^ NPY002
41 | numpy.random.logistic()
42 | numpy.random.lognormal()
   |

NPY002.py:39:1: NPY002 Replace legacy `np.random.logistic` call with `np.random.Generator`
   |
39 | numpy.random.hypergeometric()
40 | numpy.random.laplace()
41 | numpy.random.logistic()
   | ^^^^^^^^^^^^^^^^^^^^^ NPY002
42 | numpy.random.lognormal()
43 | numpy.random.logseries()
   |

NPY002.py:40:1: NPY002 Replace legacy `np.random.lognormal` call with `np.random.Generator`
   |
40 | numpy.random.laplace()
41 | numpy.random.logistic()
42 | numpy.random.lognormal()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
43 | numpy.random.logseries()
44 | numpy.random.multinomial()
   |

NPY002.py:41:1: NPY002 Replace legacy `np.random.logseries` call with `np.random.Generator`
   |
41 | numpy.random.logistic()
42 | numpy.random.lognormal()
43 | numpy.random.logseries()
   | ^^^^^^^^^^^^^^^^^^^^^^ NPY002
44 | numpy.random.multinomial()
45 | numpy.random.multivariate_normal()
   |

NPY002.py:42:1: NPY002 Replace legacy `np.random.multinomial` call with `np.random.Generator`
   |
42 | numpy.random.lognormal()
43 | numpy.random.logseries()
44 | numpy.random.multinomial()
   | ^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
45 | numpy.random.multivariate_normal()
46 | numpy.random.negative_binomial()
   |

NPY002.py:43:1: NPY002 Replace legacy `np.random.multivariate_normal` call with `np.random.Generator`
   |
43 | numpy.random.logseries()
44 | numpy.random.multinomial()
45 | numpy.random.multivariate_normal()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
46 | numpy.random.negative_binomial()
47 | numpy.random.noncentral_chisquare()
   |

NPY002.py:44:1: NPY002 Replace legacy `np.random.negative_binomial` call with `np.random.Generator`
   |
44 | numpy.random.multinomial()
45 | numpy.random.multivariate_normal()
46 | numpy.random.negative_binomial()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
47 | numpy.random.noncentral_chisquare()
48 | numpy.random.noncentral_f()
   |

NPY002.py:45:1: NPY002 Replace legacy `np.random.noncentral_chisquare` call with `np.random.Generator`
   |
45 | numpy.random.multivariate_normal()
46 | numpy.random.negative_binomial()
47 | numpy.random.noncentral_chisquare()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
48 | numpy.random.noncentral_f()
49 | numpy.random.normal()
   |

NPY002.py:46:1: NPY002 Replace legacy `np.random.noncentral_f` call with `np.random.Generator`
   |
46 | numpy.random.negative_binomial()
47 | numpy.random.noncentral_chisquare()
48 | numpy.random.noncentral_f()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
49 | numpy.random.normal()
50 | numpy.random.pareto()
   |

NPY002.py:47:1: NPY002 Replace legacy `np.random.normal` call with `np.random.Generator`
   |
47 | numpy.random.noncentral_chisquare()
48 | numpy.random.noncentral_f()
49 | numpy.random.normal()
   | ^^^^^^^^^^^^^^^^^^^ NPY002
50 | numpy.random.pareto()
51 | numpy.random.poisson()
   |

NPY002.py:48:1: NPY002 Replace legacy `np.random.pareto` call with `np.random.Generator`
   |
48 | numpy.random.noncentral_f()
49 | numpy.random.normal()
50 | numpy.random.pareto()
   | ^^^^^^^^^^^^^^^^^^^ NPY002
51 | numpy.random.poisson()
52 | numpy.random.power()
   |

NPY002.py:49:1: NPY002 Replace legacy `np.random.poisson` call with `np.random.Generator`
   |
49 | numpy.random.normal()
50 | numpy.random.pareto()
51 | numpy.random.poisson()
   | ^^^^^^^^^^^^^^^^^^^^ NPY002
52 | numpy.random.power()
53 | numpy.random.rayleigh()
   |

NPY002.py:50:1: NPY002 Replace legacy `np.random.power` call with `np.random.Generator`
   |
50 | numpy.random.pareto()
51 | numpy.random.poisson()
52 | numpy.random.power()
   | ^^^^^^^^^^^^^^^^^^ NPY002
53 | numpy.random.rayleigh()
54 | numpy.random.standard_cauchy()
   |

NPY002.py:51:1: NPY002 Replace legacy `np.random.rayleigh` call with `np.random.Generator`
   |
51 | numpy.random.poisson()
52 | numpy.random.power()
53 | numpy.random.rayleigh()
   | ^^^^^^^^^^^^^^^^^^^^^ NPY002
54 | numpy.random.standard_cauchy()
55 | numpy.random.standard_exponential()
   |

NPY002.py:52:1: NPY002 Replace legacy `np.random.standard_cauchy` call with `np.random.Generator`
   |
52 | numpy.random.power()
53 | numpy.random.rayleigh()
54 | numpy.random.standard_cauchy()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
55 | numpy.random.standard_exponential()
56 | numpy.random.standard_gamma()
   |

NPY002.py:53:1: NPY002 Replace legacy `np.random.standard_exponential` call with `np.random.Generator`
   |
53 | numpy.random.rayleigh()
54 | numpy.random.standard_cauchy()
55 | numpy.random.standard_exponential()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
56 | numpy.random.standard_gamma()
57 | numpy.random.standard_normal()
   |

NPY002.py:54:1: NPY002 Replace legacy `np.random.standard_gamma` call with `np.random.Generator`
   |
54 | numpy.random.standard_cauchy()
55 | numpy.random.standard_exponential()
56 | numpy.random.standard_gamma()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
57 | numpy.random.standard_normal()
58 | numpy.random.standard_t()
   |

NPY002.py:55:1: NPY002 Replace legacy `np.random.standard_normal` call with `np.random.Generator`
   |
55 | numpy.random.standard_exponential()
56 | numpy.random.standard_gamma()
57 | numpy.random.standard_normal()
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ NPY002
58 | numpy.random.standard_t()
59 | numpy.random.triangular()
   |

NPY002.py:56:1: NPY002 Replace legacy `np.random.standard_t` call with `np.random.Generator`
   |
56 | numpy.random.standard_gamma()
57 | numpy.random.standard_normal()
58 | numpy.random.standard_t()
   | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002
59 | numpy.random.triangular()
60 | numpy.random.uniform()
   |

NPY002.py:57:1: NPY002 Replace legacy `np.random.triangular` call with `np.random.Generator`
   |
57 | numpy.random.standard_normal()
58 | numpy.random.standard_t()
59 | numpy.random.triangular()
   | ^^^^^^^^^^^^^^^^^^^^^^^ NPY002
60 | numpy.random.uniform()
61 | numpy.random.vonmises()
   |

NPY002.py:58:1: NPY002 Replace legacy `np.random.uniform` call with `np.random.Generator`
   |
58 | numpy.random.standard_t()
59 | numpy.random.triangular()
60 | numpy.random.uniform()
   | ^^^^^^^^^^^^^^^^^^^^ NPY002
61 | numpy.random.vonmises()
62 | numpy.random.wald()
   |

NPY002.py:59:1: NPY002 Replace legacy `np.random.vonmises` call with `np.random.Generator`
   |
59 | numpy.random.triangular()
60 | numpy.random.uniform()
61 | numpy.random.vonmises()
   | ^^^^^^^^^^^^^^^^^^^^^ NPY002
62 | numpy.random.wald()
63 | numpy.random.weibull()
   |

NPY002.py:60:1: NPY002 Replace legacy `np.random.wald` call with `np.random.Generator`
   |
60 | numpy.random.uniform()
61 | numpy.random.vonmises()
62 | numpy.random.wald()
   | ^^^^^^^^^^^^^^^^^ NPY002
63 | numpy.random.weibull()
64 | numpy.random.zipf()
   |

NPY002.py:61:1: NPY002 Replace legacy `np.random.weibull` call with `np.random.Generator`
   |
61 | numpy.random.vonmises()
62 | numpy.random.wald()
63 | numpy.random.weibull()
   | ^^^^^^^^^^^^^^^^^^^^ NPY002
64 | numpy.random.zipf()
   |

NPY002.py:62:1: NPY002 Replace legacy `np.random.zipf` call with `np.random.Generator`
   |
62 | numpy.random.wald()
63 | numpy.random.weibull()
64 | numpy.random.zipf()
   | ^^^^^^^^^^^^^^^^^ NPY002
   |


