[Numpy-discussion] Behaviour of integer powers
josef.pktd@gmai...
josef.pktd@gmai...
Sun Feb 8 07:19:08 CST 2009
On Sun, Feb 8, 2009 at 8:02 AM, <josef.pktd@gmail.com> wrote:
> But I just found that nan in the exponent in an array are not propagated:
>
>>>> 0.0 ** np.array([-np.nan, 0, 1], dtype=np.int32)[0]
> 1.0
>>>> np.power(0.0, np.array([-np.nan, 0, 1], dtype=np.int32)[0])
> 1.0
correction:
np.power propagates nans, it's again the casting of nan to zero int,
that tripped me up.
I shouln't cut and paste examples too fast.
>>> np.power(0.0, np.array([-np.nan, 0, 1]))
array([ NaN, 1., 0.])
>>> np.power(0.0, np.array([-np.nan, 0, 1]))[0]
1.#QNAN
Josef
More information about the Numpy-discussion
mailing list