Numpy array not updated when assigning unexpected value to dtype('int64') using math.erf() -
i'm trying write output of math.erf()
numpy array. i'm doing is:
import numpy np import math a=np.array([0,0,0]) a[0]=math.erf(5)
however, never updated hold values of output of math.erf()
should float. doing wrong?
update
when a
created list via a=np.asarray(a)
, seems work.
it updated, doesn't alter type of array hence value not appear change. notice that
a=np.array([0,0,0]) a.dtype
returns
dtype('int64')
since math.erf(5)
<1 integer zero.
as alternative (there many ways create array of particular type)
a=np.array([0,0,0],dtype=float) a[0]=math.erf(5)
does expect.
arrays math numpy int
No comments:
Post a Comment