Skip to content

numpy/numpy-import-alias

Rule numpy-import-alias
Pack NumPy
Severity info
Fix none, edit by hand
Library versions every version

NumPy's docs import it as np, and other code and the fixes of this pack expect that name. Write import numpy as np.

import numpy as N
import numpy as np

The rule reports import numpy as <name> with a name other than np or xp, and from numpy import *, which replaces Python's sum, min, max, round, abs, all and any.

xpd has no automatic fix. Because every use of the old name changes with the import. Make the change by hand.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

NumPy's docs import it as np, and other code and the fixes of this pack expect that name. Write import numpy as np.

Browse the other rules of the NumPy pack.