---
source: crates/ruff_linter/src/rules/numpy/mod.rs
snapshot_kind: text
---
NPY001.py:6:1: NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type
  |
5 | # Error
6 | npy.float
  | ^^^^^^^^^ NPY001
7 | npy.int
  |
  = help: Replace `np.float` with builtin type

ℹ Safe fix
3 3 | import numpy
4 4 | 
5 5 | # Error
6   |-npy.float
  6 |+float
7 7 | npy.int
8 8 | 
9 9 | if dtype == np.object:

NPY001.py:7:1: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type
  |
5 | # Error
6 | npy.float
7 | npy.int
  | ^^^^^^^ NPY001
8 | 
9 | if dtype == np.object:
  |
  = help: Replace `np.int` with builtin type

ℹ Safe fix
4 4 | 
5 5 | # Error
6 6 | npy.float
7   |-npy.int
  7 |+int
8 8 | 
9 9 | if dtype == np.object:
10 10 |     ...

NPY001.py:9:13: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type
   |
 7 | npy.int
 8 | 
 9 | if dtype == np.object:
   |             ^^^^^^^^^ NPY001
10 |     ...
   |
   = help: Replace `np.object` with builtin type

ℹ Safe fix
6  6  | npy.float
7  7  | npy.int
8  8  | 
9     |-if dtype == np.object:
   9  |+if dtype == object:
10 10 |     ...
11 11 | 
12 12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex])

NPY001.py:12:72: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type
   |
10 |     ...
11 | 
12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex])
   |                                                                        ^^^^^^ NPY001
13 | 
14 | pdf = pd.DataFrame(
   |
   = help: Replace `np.int` with builtin type

ℹ Safe fix
9  9  | if dtype == np.object:
10 10 |     ...
11 11 | 
12    |-result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex])
   12 |+result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, int, np.complex])
13 13 | 
14 14 | pdf = pd.DataFrame(
15 15 |     data=[[1, 2, 3]],

NPY001.py:12:80: NPY001 [*] Type alias `np.complex` is deprecated, replace with builtin type
   |
10 |     ...
11 | 
12 | result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex])
   |                                                                                ^^^^^^^^^^ NPY001
13 | 
14 | pdf = pd.DataFrame(
   |
   = help: Replace `np.complex` with builtin type

ℹ Safe fix
9  9  | if dtype == np.object:
10 10 |     ...
11 11 | 
12    |-result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, np.complex])
   12 |+result = result.select_dtypes([np.byte, np.ubyte, np.short, np.ushort, np.int, complex])
13 13 | 
14 14 | pdf = pd.DataFrame(
15 15 |     data=[[1, 2, 3]],

NPY001.py:17:11: NPY001 [*] Type alias `np.object` is deprecated, replace with builtin type
   |
15 |     data=[[1, 2, 3]],
16 |     columns=["a", "b", "c"],
17 |     dtype=numpy.object,
   |           ^^^^^^^^^^^^ NPY001
18 | )
   |
   = help: Replace `np.object` with builtin type

ℹ Safe fix
14 14 | pdf = pd.DataFrame(
15 15 |     data=[[1, 2, 3]],
16 16 |     columns=["a", "b", "c"],
17    |-    dtype=numpy.object,
   17 |+    dtype=object,
18 18 | )
19 19 | 
20 20 | _ = arr.astype(np.int)

NPY001.py:20:16: NPY001 [*] Type alias `np.int` is deprecated, replace with builtin type
   |
18 | )
19 | 
20 | _ = arr.astype(np.int)
   |                ^^^^^^ NPY001
21 | 
22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952
   |
   = help: Replace `np.int` with builtin type

ℹ Safe fix
17 17 |     dtype=numpy.object,
18 18 | )
19 19 | 
20    |-_ = arr.astype(np.int)
   20 |+_ = arr.astype(int)
21 21 | 
22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952
23 23 | from numpy import float

NPY001.py:25:1: NPY001 [*] Type alias `np.float` is deprecated, replace with builtin type
   |
23 | from numpy import float
24 | 
25 | float(1)
   | ^^^^^ NPY001
   |
   = help: Replace `np.float` with builtin type

ℹ Safe fix
21 21 | 
22 22 | # Regression test for: https://github.com/astral-sh/ruff/issues/6952
23 23 | from numpy import float
   24 |+import builtins
24 25 | 
25    |-float(1)
   26 |+builtins.float(1)
