---
source: crates/ruff_linter/src/rules/numpy/mod.rs
---
NPY201 `np.obj2sctype` will be removed without replacement in NumPy 2.0
 --> NPY201_2.py:4:5
  |
2 |     import numpy as np
3 |
4 |     np.obj2sctype(int)
  |     ^^^^^^^^^^^^^
5 |
6 |     np.PINF
  |

NPY201 [*] `np.PINF` will be removed in NumPy 2.0. Use `numpy.inf` instead.
 --> NPY201_2.py:6:5
  |
4 |     np.obj2sctype(int)
5 |
6 |     np.PINF
  |     ^^^^^^^
7 |
8 |     np.PZERO
  |
help: Replace with `numpy.inf`
  |
5 |
  -     np.PINF
6 +     np.inf
7 |
  |

NPY201 [*] `np.PZERO` will be removed in NumPy 2.0. Use `0.0` instead.
  --> NPY201_2.py:8:5
   |
 6 |     np.PINF
 7 |
 8 |     np.PZERO
   |     ^^^^^^^^
 9 |
10 |     np.recfromcsv
   |
help: Replace with `0.0`
  |
7 |
  -     np.PZERO
8 +     0.0
9 |
  |

NPY201 `np.recfromcsv` will be removed in NumPy 2.0. Use `np.genfromtxt` with comma delimiter instead.
  --> NPY201_2.py:10:5
   |
 8 |     np.PZERO
 9 |
10 |     np.recfromcsv
   |     ^^^^^^^^^^^^^
11 |
12 |     np.recfromtxt
   |

NPY201 `np.recfromtxt` will be removed in NumPy 2.0. Use `np.genfromtxt` instead.
  --> NPY201_2.py:12:5
   |
10 |     np.recfromcsv
11 |
12 |     np.recfromtxt
   |     ^^^^^^^^^^^^^
13 |
14 |     np.round_(12.34)
   |

NPY201 [*] `np.round_` will be removed in NumPy 2.0. Use `numpy.round` instead.
  --> NPY201_2.py:14:5
   |
12 |     np.recfromtxt
13 |
14 |     np.round_(12.34)
   |     ^^^^^^^^^
15 |
16 |     np.safe_eval
   |
help: Replace with `numpy.round`
   |
13 |
   -     np.round_(12.34)
14 +     np.round(12.34)
15 |
   |

NPY201 [*] `np.safe_eval` will be removed in NumPy 2.0. Use `ast.literal_eval` instead.
  --> NPY201_2.py:16:5
   |
14 |     np.round_(12.34)
15 |
16 |     np.safe_eval
   |     ^^^^^^^^^^^^
17 |
18 |     np.sctype2char
   |
help: Replace with `ast.literal_eval`
   |
1  + from ast import literal_eval
2  | def func():
--------------------------------------------------------------------------------
16 |
   -     np.safe_eval
17 +     literal_eval
18 |
   |

NPY201 `np.sctype2char` will be removed without replacement in NumPy 2.0
  --> NPY201_2.py:18:5
   |
16 |     np.safe_eval
17 |
18 |     np.sctype2char
   |     ^^^^^^^^^^^^^^
19 |
20 |     np.sctypes
   |

NPY201 `np.sctypes` will be removed without replacement in NumPy 2.0
  --> NPY201_2.py:20:5
   |
18 |     np.sctype2char
19 |
20 |     np.sctypes
   |     ^^^^^^^^^^
21 |
22 |     np.seterrobj
   |

NPY201 `np.seterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead.
  --> NPY201_2.py:22:5
   |
20 |     np.sctypes
21 |
22 |     np.seterrobj
   |     ^^^^^^^^^^^^
23 |
24 |     np.set_numeric_ops
   |

NPY201 `np.set_string_function` will be removed in NumPy 2.0. Use `np.set_printoptions` for custom printing of NumPy objects.
  --> NPY201_2.py:26:5
   |
24 |     np.set_numeric_ops
25 |
26 |     np.set_string_function
   |     ^^^^^^^^^^^^^^^^^^^^^^
27 |
28 |     np.singlecomplex(12+1j)
   |

NPY201 [*] `np.singlecomplex` will be removed in NumPy 2.0. Use `numpy.complex64` instead.
  --> NPY201_2.py:28:5
   |
26 |     np.set_string_function
27 |
28 |     np.singlecomplex(12+1j)
   |     ^^^^^^^^^^^^^^^^
29 |
30 |     np.string_("asdf")
   |
help: Replace with `numpy.complex64`
   |
27 |
   -     np.singlecomplex(12+1j)
28 +     np.complex64(12+1j)
29 |
   |

NPY201 [*] `np.string_` will be removed in NumPy 2.0. Use `numpy.bytes_` instead.
  --> NPY201_2.py:30:5
   |
28 |     np.singlecomplex(12+1j)
29 |
30 |     np.string_("asdf")
   |     ^^^^^^^^^^
31 |
32 |     np.source
   |
help: Replace with `numpy.bytes_`
   |
29 |
   -     np.string_("asdf")
30 +     np.bytes_("asdf")
31 |
   |

NPY201 [*] `np.source` will be removed in NumPy 2.0. Use `inspect.getsource` instead.
  --> NPY201_2.py:32:5
   |
30 |     np.string_("asdf")
31 |
32 |     np.source
   |     ^^^^^^^^^
33 |
34 |     np.tracemalloc_domain
   |
help: Replace with `inspect.getsource`
   |
1  + from inspect import getsource
2  | def func():
--------------------------------------------------------------------------------
32 |
   -     np.source
33 +     getsource
34 |
   |

NPY201 [*] `np.tracemalloc_domain` will be removed in NumPy 2.0. Use `numpy.lib.tracemalloc_domain` instead.
  --> NPY201_2.py:34:5
   |
32 |     np.source
33 |
34 |     np.tracemalloc_domain
   |     ^^^^^^^^^^^^^^^^^^^^^
35 |
36 |     np.unicode_("asf")
   |
help: Replace with `numpy.lib.tracemalloc_domain`
   |
1  + from numpy.lib import tracemalloc_domain
2  | def func():
--------------------------------------------------------------------------------
34 |
   -     np.tracemalloc_domain
35 +     tracemalloc_domain
36 |
   |

NPY201 [*] `np.unicode_` will be removed in NumPy 2.0. Use `numpy.str_` instead.
  --> NPY201_2.py:36:5
   |
34 |     np.tracemalloc_domain
35 |
36 |     np.unicode_("asf")
   |     ^^^^^^^^^^^
37 |
38 |     np.who()
   |
help: Replace with `numpy.str_`
   |
35 |
   -     np.unicode_("asf")
36 +     np.str_("asf")
37 |
   |

NPY201 `np.who` will be removed in NumPy 2.0. Use an IDE variable explorer or `locals()` instead.
  --> NPY201_2.py:38:5
   |
36 |     np.unicode_("asf")
37 |
38 |     np.who()
   |     ^^^^^^
39 |
40 |     np.row_stack(([1,2], [3,4]))
   |

NPY201 [*] `np.row_stack` will be removed in NumPy 2.0. Use `numpy.vstack` instead.
  --> NPY201_2.py:40:5
   |
38 |     np.who()
39 |
40 |     np.row_stack(([1,2], [3,4]))
   |     ^^^^^^^^^^^^
41 |
42 |     np.alltrue([True, True])
   |
help: Replace with `numpy.vstack`
   |
39 |
   -     np.row_stack(([1,2], [3,4]))
40 +     np.vstack(([1,2], [3,4]))
41 |
   |

NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead.
  --> NPY201_2.py:42:5
   |
40 |     np.row_stack(([1,2], [3,4]))
41 |
42 |     np.alltrue([True, True])
   |     ^^^^^^^^^^
43 |
44 |     np.sometrue([True, False])
   |
help: Replace with `numpy.all`
   |
41 |
   -     np.alltrue([True, True])
42 +     np.all([True, True])
43 |
   |

NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead.
  --> NPY201_2.py:44:5
   |
42 |     np.alltrue([True, True])
43 |
44 |     np.sometrue([True, False])
   |     ^^^^^^^^^^^
45 |
46 |     np.cumproduct([1, 2, 3])
   |
help: Replace with `numpy.any`
   |
43 |
   -     np.sometrue([True, False])
44 +     np.any([True, False])
45 |
   |

NPY201 [*] `np.cumproduct` will be removed in NumPy 2.0. Use `numpy.cumprod` instead.
  --> NPY201_2.py:46:5
   |
44 |     np.sometrue([True, False])
45 |
46 |     np.cumproduct([1, 2, 3])
   |     ^^^^^^^^^^^^^
47 |
48 |     np.product([1, 2, 3])
   |
help: Replace with `numpy.cumprod`
   |
45 |
   -     np.cumproduct([1, 2, 3])
46 +     np.cumprod([1, 2, 3])
47 |
   |

NPY201 [*] `np.product` will be removed in NumPy 2.0. Use `numpy.prod` instead.
  --> NPY201_2.py:48:5
   |
46 |     np.cumproduct([1, 2, 3])
47 |
48 |     np.product([1, 2, 3])
   |     ^^^^^^^^^^
49 |
50 |     np.trapz([1, 2, 3])
   |
help: Replace with `numpy.prod`
   |
47 |
   -     np.product([1, 2, 3])
48 +     np.prod([1, 2, 3])
49 |
   |

NPY201 [*] `np.trapz` will be removed in NumPy 2.0. Use `numpy.trapezoid` on NumPy 2.0, or ignore this warning on earlier versions.
  --> NPY201_2.py:50:5
   |
48 |     np.product([1, 2, 3])
49 |
50 |     np.trapz([1, 2, 3])
   |     ^^^^^^^^
51 |
52 |     np.in1d([1, 2], [1, 3, 5])
   |
help: Replace with `numpy.trapezoid` (requires NumPy 2.0 or greater)
   |
49 |
   -     np.trapz([1, 2, 3])
50 +     np.trapezoid([1, 2, 3])
51 |
   |
note: This is an unsafe fix and may change runtime behavior

NPY201 `np.in1d` will be removed in NumPy 2.0. Use `np.isin` instead. Unlike `np.in1d`, `np.isin` preserves the shape of its input, so `np.in1d(ar1, ar2)` is equivalent to `np.isin(ar1, ar2).ravel()`.
  --> NPY201_2.py:52:5
   |
50 |     np.trapz([1, 2, 3])
51 |
52 |     np.in1d([1, 2], [1, 3, 5])
   |     ^^^^^^^
53 |
54 |     np.AxisError
   |

NPY201 [*] `np.AxisError` will be removed in NumPy 2.0. Use `numpy.exceptions.AxisError` instead.
  --> NPY201_2.py:54:5
   |
52 |     np.in1d([1, 2], [1, 3, 5])
53 |
54 |     np.AxisError
   |     ^^^^^^^^^^^^
55 |
56 |     np.ComplexWarning
   |
help: Replace with `numpy.exceptions.AxisError`
   |
1  + from numpy.exceptions import AxisError
2  | def func():
--------------------------------------------------------------------------------
54 |
   -     np.AxisError
55 +     AxisError
56 |
   |

NPY201 [*] `np.ComplexWarning` will be removed in NumPy 2.0. Use `numpy.exceptions.ComplexWarning` instead.
  --> NPY201_2.py:56:5
   |
54 |     np.AxisError
55 |
56 |     np.ComplexWarning
   |     ^^^^^^^^^^^^^^^^^
57 |
58 |     np.compare_chararrays
   |
help: Replace with `numpy.exceptions.ComplexWarning`
   |
1  + from numpy.exceptions import ComplexWarning
2  | def func():
--------------------------------------------------------------------------------
56 |
   -     np.ComplexWarning
57 +     ComplexWarning
58 |
   |

NPY201 [*] `np.compare_chararrays` will be removed in NumPy 2.0. Use `numpy.char.compare_chararrays` instead.
  --> NPY201_2.py:58:5
   |
56 |     np.ComplexWarning
57 |
58 |     np.compare_chararrays
   |     ^^^^^^^^^^^^^^^^^^^^^
59 |
60 |     try:
   |
help: Replace with `numpy.char.compare_chararrays`
   |
1  + from numpy.char import compare_chararrays
2  | def func():
--------------------------------------------------------------------------------
58 |
   -     np.compare_chararrays
59 +     compare_chararrays
60 |
   |

NPY201 [*] `np.alltrue` will be removed in NumPy 2.0. Use `numpy.all` instead.
  --> NPY201_2.py:63:9
   |
61 |         np.all([True, True])
62 |     except TypeError:
63 |         np.alltrue([True, True])  # Should emit a warning here (`except TypeError`, not `except AttributeError`)
   |         ^^^^^^^^^^
64 |
65 |     try:
   |
help: Replace with `numpy.all`
   |
62 |     except TypeError:
   -         np.alltrue([True, True])  # Should emit a warning here (`except TypeError`, not `except AttributeError`)
63 +         np.all([True, True])  # Should emit a warning here (`except TypeError`, not `except AttributeError`)
64 |
   |

NPY201 [*] `np.sometrue` will be removed in NumPy 2.0. Use `numpy.any` instead.
  --> NPY201_2.py:68:9
   |
66 |         np.anyyyy([True, True])
67 |     except AttributeError:
68 |         np.sometrue([True, True])  # Should emit a warning here
   |         ^^^^^^^^^^^
69 |                                    # (must have an attribute access of the undeprecated name in the `try` body for it to be ignored)
   |
help: Replace with `numpy.any`
   |
67 |     except AttributeError:
   -         np.sometrue([True, True])  # Should emit a warning here
68 +         np.any([True, True])  # Should emit a warning here
69 |                                    # (must have an attribute access of the undeprecated name in the `try` body for it to be ignored)
   |
