---
source: crates/ruff_linter/src/rules/numpy/mod.rs
snapshot_kind: text
---
NPY201.py:4:5: NPY201 [*] `np.add_docstring` will be removed in NumPy 2.0. Use `numpy.lib.add_docstring` instead.
  |
2 |     import numpy as np
3 | 
4 |     np.add_docstring
  |     ^^^^^^^^^^^^^^^^ NPY201
5 | 
6 |     np.add_newdoc
  |
  = help: Replace with `numpy.lib.add_docstring`

ℹ Safe fix
  1 |+from numpy.lib import add_docstring
1 2 | def func():
2 3 |     import numpy as np
3 4 | 
4   |-    np.add_docstring
  5 |+    add_docstring
5 6 | 
6 7 |     np.add_newdoc
7 8 | 

NPY201.py:6:5: NPY201 [*] `np.add_newdoc` will be removed in NumPy 2.0. Use `numpy.lib.add_newdoc` instead.
  |
4 |     np.add_docstring
5 | 
6 |     np.add_newdoc
  |     ^^^^^^^^^^^^^ NPY201
7 | 
8 |     np.add_newdoc_ufunc
  |
  = help: Replace with `numpy.lib.add_newdoc`

ℹ Safe fix
  1 |+from numpy.lib import add_newdoc
1 2 | def func():
2 3 |     import numpy as np
3 4 | 
4 5 |     np.add_docstring
5 6 | 
6   |-    np.add_newdoc
  7 |+    add_newdoc
7 8 | 
8 9 |     np.add_newdoc_ufunc
9 10 | 

NPY201.py:8:5: NPY201 `np.add_newdoc_ufunc` will be removed in NumPy 2.0. `add_newdoc_ufunc` is an internal function.
   |
 6 |     np.add_newdoc
 7 | 
 8 |     np.add_newdoc_ufunc
   |     ^^^^^^^^^^^^^^^^^^^ NPY201
 9 | 
10 |     np.asfarray([1,2,3])
   |

NPY201.py:10:5: NPY201 `np.asfarray` will be removed in NumPy 2.0. Use `np.asarray` with a `float` dtype instead.
   |
 8 |     np.add_newdoc_ufunc
 9 | 
10 |     np.asfarray([1,2,3])
   |     ^^^^^^^^^^^ NPY201
11 | 
12 |     np.byte_bounds(np.array([1,2,3]))
   |

NPY201.py:12:5: NPY201 [*] `np.byte_bounds` will be removed in NumPy 2.0. Use `numpy.lib.array_utils.byte_bounds` on NumPy 2.0, or ignore this warning on earlier versions.
   |
10 |     np.asfarray([1,2,3])
11 | 
12 |     np.byte_bounds(np.array([1,2,3]))
   |     ^^^^^^^^^^^^^^ NPY201
13 | 
14 |     np.cast
   |
   = help: Replace with `numpy.lib.array_utils.byte_bounds` (requires NumPy 2.0 or greater)

ℹ Unsafe fix
   1  |+from numpy.lib.array_utils import byte_bounds
1  2  | def func():
2  3  |     import numpy as np
3  4  | 
--------------------------------------------------------------------------------
9  10 | 
10 11 |     np.asfarray([1,2,3])
11 12 | 
12    |-    np.byte_bounds(np.array([1,2,3]))
   13 |+    byte_bounds(np.array([1,2,3]))
13 14 | 
14 15 |     np.cast
15 16 | 

NPY201.py:14:5: NPY201 `np.cast` will be removed in NumPy 2.0. Use `np.asarray(arr, dtype=dtype)` instead.
   |
12 |     np.byte_bounds(np.array([1,2,3]))
13 | 
14 |     np.cast
   |     ^^^^^^^ NPY201
15 | 
16 |     np.cfloat(12+34j)
   |

NPY201.py:16:5: NPY201 [*] `np.cfloat` will be removed in NumPy 2.0. Use `numpy.complex128` instead.
   |
14 |     np.cast
15 | 
16 |     np.cfloat(12+34j)
   |     ^^^^^^^^^ NPY201
17 | 
18 |     np.clongfloat(12+34j)
   |
   = help: Replace with `numpy.complex128`

ℹ Safe fix
13 13 | 
14 14 |     np.cast
15 15 | 
16    |-    np.cfloat(12+34j)
   16 |+    np.complex128(12+34j)
17 17 | 
18 18 |     np.clongfloat(12+34j)
19 19 | 

NPY201.py:18:5: NPY201 [*] `np.clongfloat` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead.
   |
16 |     np.cfloat(12+34j)
17 | 
18 |     np.clongfloat(12+34j)
   |     ^^^^^^^^^^^^^ NPY201
19 | 
20 |     np.compat
   |
   = help: Replace with `numpy.clongdouble`

ℹ Safe fix
15 15 | 
16 16 |     np.cfloat(12+34j)
17 17 | 
18    |-    np.clongfloat(12+34j)
   18 |+    np.clongdouble(12+34j)
19 19 | 
20 20 |     np.compat
21 21 | 

NPY201.py:20:5: NPY201 `np.compat` will be removed in NumPy 2.0. Python 2 is no longer supported.
   |
18 |     np.clongfloat(12+34j)
19 | 
20 |     np.compat
   |     ^^^^^^^^^ NPY201
21 | 
22 |     np.complex_(12+34j)
   |

NPY201.py:22:5: NPY201 [*] `np.complex_` will be removed in NumPy 2.0. Use `numpy.complex128` instead.
   |
20 |     np.compat
21 | 
22 |     np.complex_(12+34j)
   |     ^^^^^^^^^^^ NPY201
23 | 
24 |     np.DataSource
   |
   = help: Replace with `numpy.complex128`

ℹ Safe fix
19 19 | 
20 20 |     np.compat
21 21 | 
22    |-    np.complex_(12+34j)
   22 |+    np.complex128(12+34j)
23 23 | 
24 24 |     np.DataSource
25 25 | 

NPY201.py:24:5: NPY201 [*] `np.DataSource` will be removed in NumPy 2.0. Use `numpy.lib.npyio.DataSource` instead.
   |
22 |     np.complex_(12+34j)
23 | 
24 |     np.DataSource
   |     ^^^^^^^^^^^^^ NPY201
25 | 
26 |     np.deprecate
   |
   = help: Replace with `numpy.lib.npyio.DataSource`

ℹ Safe fix
   1  |+from numpy.lib.npyio import DataSource
1  2  | def func():
2  3  |     import numpy as np
3  4  | 
--------------------------------------------------------------------------------
21 22 | 
22 23 |     np.complex_(12+34j)
23 24 | 
24    |-    np.DataSource
   25 |+    DataSource
25 26 | 
26 27 |     np.deprecate
27 28 | 

NPY201.py:26:5: NPY201 `np.deprecate` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`.
   |
24 |     np.DataSource
25 | 
26 |     np.deprecate
   |     ^^^^^^^^^^^^ NPY201
27 | 
28 |     np.deprecate_with_doc
   |

NPY201.py:28:5: NPY201 `np.deprecate_with_doc` will be removed in NumPy 2.0. Emit `DeprecationWarning` with `warnings.warn` directly, or use `typing.deprecated`.
   |
26 |     np.deprecate
27 | 
28 |     np.deprecate_with_doc
   |     ^^^^^^^^^^^^^^^^^^^^^ NPY201
29 | 
30 |     np.disp(10)
   |

NPY201.py:30:5: NPY201 `np.disp` will be removed in NumPy 2.0. Use a dedicated print function instead.
   |
28 |     np.deprecate_with_doc
29 | 
30 |     np.disp(10)
   |     ^^^^^^^ NPY201
31 | 
32 |     np.fastCopyAndTranspose
   |

NPY201.py:32:5: NPY201 `np.fastCopyAndTranspose` will be removed in NumPy 2.0. Use `arr.T.copy()` instead.
   |
30 |     np.disp(10)
31 | 
32 |     np.fastCopyAndTranspose
   |     ^^^^^^^^^^^^^^^^^^^^^^^ NPY201
33 | 
34 |     np.find_common_type
   |

NPY201.py:34:5: NPY201 `np.find_common_type` will be removed in NumPy 2.0. Use `numpy.promote_types` or `numpy.result_type` instead. To achieve semantics for the `scalar_types` argument, use `numpy.result_type` and pass the Python values `0`, `0.0`, or `0j`.
   |
32 |     np.fastCopyAndTranspose
33 | 
34 |     np.find_common_type
   |     ^^^^^^^^^^^^^^^^^^^ NPY201
35 | 
36 |     np.get_array_wrap
   |

NPY201.py:36:5: NPY201 `np.get_array_wrap` will be removed without replacement in NumPy 2.0
   |
34 |     np.find_common_type
35 | 
36 |     np.get_array_wrap
   |     ^^^^^^^^^^^^^^^^^ NPY201
37 | 
38 |     np.float_
   |

NPY201.py:38:5: NPY201 [*] `np.float_` will be removed in NumPy 2.0. Use `numpy.float64` instead.
   |
36 |     np.get_array_wrap
37 | 
38 |     np.float_
   |     ^^^^^^^^^ NPY201
39 | 
40 |     np.geterrobj
   |
   = help: Replace with `numpy.float64`

ℹ Safe fix
35 35 | 
36 36 |     np.get_array_wrap
37 37 | 
38    |-    np.float_
   38 |+    np.float64
39 39 | 
40 40 |     np.geterrobj
41 41 | 

NPY201.py:40:5: NPY201 `np.geterrobj` will be removed in NumPy 2.0. Use the `np.errstate` context manager instead.
   |
38 |     np.float_
39 | 
40 |     np.geterrobj
   |     ^^^^^^^^^^^^ NPY201
41 | 
42 |     np.Inf
   |

NPY201.py:42:5: NPY201 [*] `np.Inf` will be removed in NumPy 2.0. Use `numpy.inf` instead.
   |
40 |     np.geterrobj
41 | 
42 |     np.Inf
   |     ^^^^^^ NPY201
43 | 
44 |     np.Infinity
   |
   = help: Replace with `numpy.inf`

ℹ Safe fix
39 39 | 
40 40 |     np.geterrobj
41 41 | 
42    |-    np.Inf
   42 |+    np.inf
43 43 | 
44 44 |     np.Infinity
45 45 | 

NPY201.py:44:5: NPY201 [*] `np.Infinity` will be removed in NumPy 2.0. Use `numpy.inf` instead.
   |
42 |     np.Inf
43 | 
44 |     np.Infinity
   |     ^^^^^^^^^^^ NPY201
45 | 
46 |     np.infty
   |
   = help: Replace with `numpy.inf`

ℹ Safe fix
41 41 | 
42 42 |     np.Inf
43 43 | 
44    |-    np.Infinity
   44 |+    np.inf
45 45 | 
46 46 |     np.infty
47 47 | 

NPY201.py:46:5: NPY201 [*] `np.infty` will be removed in NumPy 2.0. Use `numpy.inf` instead.
   |
44 |     np.Infinity
45 | 
46 |     np.infty
   |     ^^^^^^^^ NPY201
47 | 
48 |     np.issctype
   |
   = help: Replace with `numpy.inf`

ℹ Safe fix
43 43 | 
44 44 |     np.Infinity
45 45 | 
46    |-    np.infty
   46 |+    np.inf
47 47 | 
48 48 |     np.issctype
49 49 | 

NPY201.py:48:5: NPY201 `np.issctype` will be removed without replacement in NumPy 2.0
   |
46 |     np.infty
47 | 
48 |     np.issctype
   |     ^^^^^^^^^^^ NPY201
49 | 
50 |     np.issubclass_(np.int32, np.integer)
   |

NPY201.py:50:5: NPY201 [*] `np.issubclass_` will be removed in NumPy 2.0. Use `issubclass` instead.
   |
48 |     np.issctype
49 | 
50 |     np.issubclass_(np.int32, np.integer)
   |     ^^^^^^^^^^^^^^ NPY201
51 | 
52 |     np.issubsctype
   |
   = help: Replace with `issubclass`

ℹ Safe fix
47 47 | 
48 48 |     np.issctype
49 49 | 
50    |-    np.issubclass_(np.int32, np.integer)
   50 |+    issubclass(np.int32, np.integer)
51 51 | 
52 52 |     np.issubsctype
53 53 | 

NPY201.py:52:5: NPY201 [*] `np.issubsctype` will be removed in NumPy 2.0. Use `numpy.issubdtype` instead.
   |
50 |     np.issubclass_(np.int32, np.integer)
51 | 
52 |     np.issubsctype
   |     ^^^^^^^^^^^^^^ NPY201
53 | 
54 |     np.mat
   |
   = help: Replace with `numpy.issubdtype`

ℹ Safe fix
49 49 | 
50 50 |     np.issubclass_(np.int32, np.integer)
51 51 | 
52    |-    np.issubsctype
   52 |+    np.issubdtype
53 53 | 
54 54 |     np.mat
55 55 | 

NPY201.py:54:5: NPY201 [*] `np.mat` will be removed in NumPy 2.0. Use `numpy.asmatrix` instead.
   |
52 |     np.issubsctype
53 | 
54 |     np.mat
   |     ^^^^^^ NPY201
55 | 
56 |     np.maximum_sctype
   |
   = help: Replace with `numpy.asmatrix`

ℹ Safe fix
51 51 | 
52 52 |     np.issubsctype
53 53 | 
54    |-    np.mat
   54 |+    np.asmatrix
55 55 | 
56 56 |     np.maximum_sctype
57 57 | 

NPY201.py:56:5: NPY201 `np.maximum_sctype` will be removed without replacement in NumPy 2.0
   |
54 |     np.mat
55 | 
56 |     np.maximum_sctype
   |     ^^^^^^^^^^^^^^^^^ NPY201
57 | 
58 |     np.NaN
   |

NPY201.py:58:5: NPY201 [*] `np.NaN` will be removed in NumPy 2.0. Use `numpy.nan` instead.
   |
56 |     np.maximum_sctype
57 | 
58 |     np.NaN
   |     ^^^^^^ NPY201
59 | 
60 |     np.nbytes[np.int64]
   |
   = help: Replace with `numpy.nan`

ℹ Safe fix
55 55 | 
56 56 |     np.maximum_sctype
57 57 | 
58    |-    np.NaN
   58 |+    np.nan
59 59 | 
60 60 |     np.nbytes[np.int64]
61 61 | 

NPY201.py:60:5: NPY201 `np.nbytes` will be removed in NumPy 2.0. Use `np.dtype(<dtype>).itemsize` instead.
   |
58 |     np.NaN
59 | 
60 |     np.nbytes[np.int64]
   |     ^^^^^^^^^ NPY201
61 | 
62 |     np.NINF
   |

NPY201.py:62:5: NPY201 [*] `np.NINF` will be removed in NumPy 2.0. Use `-np.inf` instead.
   |
60 |     np.nbytes[np.int64]
61 | 
62 |     np.NINF
   |     ^^^^^^^ NPY201
63 | 
64 |     np.NZERO
   |
   = help: Replace with `-np.inf`

ℹ Safe fix
59 59 | 
60 60 |     np.nbytes[np.int64]
61 61 | 
62    |-    np.NINF
   62 |+    -np.inf
63 63 | 
64 64 |     np.NZERO
65 65 | 

NPY201.py:64:5: NPY201 [*] `np.NZERO` will be removed in NumPy 2.0. Use `-0.0` instead.
   |
62 |     np.NINF
63 | 
64 |     np.NZERO
   |     ^^^^^^^^ NPY201
65 | 
66 |     np.longcomplex(12+34j)
   |
   = help: Replace with `-0.0`

ℹ Safe fix
61 61 | 
62 62 |     np.NINF
63 63 | 
64    |-    np.NZERO
   64 |+    -0.0
65 65 | 
66 66 |     np.longcomplex(12+34j)
67 67 | 

NPY201.py:66:5: NPY201 [*] `np.longcomplex` will be removed in NumPy 2.0. Use `numpy.clongdouble` instead.
   |
64 |     np.NZERO
65 | 
66 |     np.longcomplex(12+34j)
   |     ^^^^^^^^^^^^^^ NPY201
67 | 
68 |     np.longfloat(12+34j)
   |
   = help: Replace with `numpy.clongdouble`

ℹ Safe fix
63 63 | 
64 64 |     np.NZERO
65 65 | 
66    |-    np.longcomplex(12+34j)
   66 |+    np.clongdouble(12+34j)
67 67 | 
68 68 |     np.longfloat(12+34j)
69 69 | 

NPY201.py:68:5: NPY201 [*] `np.longfloat` will be removed in NumPy 2.0. Use `numpy.longdouble` instead.
   |
66 |     np.longcomplex(12+34j)
67 | 
68 |     np.longfloat(12+34j)
   |     ^^^^^^^^^^^^ NPY201
69 | 
70 |     np.lookfor
   |
   = help: Replace with `numpy.longdouble`

ℹ Safe fix
65 65 | 
66 66 |     np.longcomplex(12+34j)
67 67 | 
68    |-    np.longfloat(12+34j)
   68 |+    np.longdouble(12+34j)
69 69 | 
70 70 |     np.lookfor
71 71 | 

NPY201.py:70:5: NPY201 `np.lookfor` will be removed in NumPy 2.0. Search NumPy’s documentation directly.
   |
68 |     np.longfloat(12+34j)
69 | 
70 |     np.lookfor
   |     ^^^^^^^^^^ NPY201
71 | 
72 |     np.NAN
   |

NPY201.py:72:5: NPY201 [*] `np.NAN` will be removed in NumPy 2.0. Use `numpy.nan` instead.
   |
70 |     np.lookfor
71 | 
72 |     np.NAN
   |     ^^^^^^ NPY201
73 | 
74 |     try:
   |
   = help: Replace with `numpy.nan`

ℹ Safe fix
69 69 | 
70 70 |     np.lookfor
71 71 | 
72    |-    np.NAN
   72 |+    np.nan
73 73 | 
74 74 |     try:
75 75 |         from numpy.lib.npyio import DataSource
