I am observing this weird behavior when I am raising an integer to the negative power using an np.array
. Specifically, I am doing
import numpy as np
a = 10**(np.arange(-1, -8, -1))
and it results in the following error.
ValueError: Integers to negative integer powers are not allowed.
This is strange as the code 10**(-1)
works fine. However the following workaround (where 10
is a float instead of integer) works fine.
import numpy as np
a = 10.**(np.arange(-1, -8, -1)
print(a) # Prints array([1.e-01, 1.e-02, 1.e-03, 1.e-04, 1.e-05, 1.e-06, 1.e-07])
Why is it not valid for integers? Any explanation is appreciated.