shaare.it

DeprecationWarning: deprecated NumPy feature

7 Dec 2025

1 min read

DeprecationWarning: deprecated NumPy feature

$ python - <<'PY'
import numpy as np
np.int
PY
/tmp/...: DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`.

Why this happens

NumPy authors remove old aliases and behaviors to encourage clearer types and avoid ambiguity.

Fix

Replace deprecated aliases with the recommended builtins or explicit dtypes (e.g., use int, np.int_).

Wrong code

import numpy as np
arr = np.array([1,2], dtype=np.int)

Fixed code

import numpy as np
arr = np.array([1,2], dtype=int)