Assign NaN, get zero
Stefan van der Walt
stefan at sun.ac.za
Sat Nov 11 16:10:46 CST 2006
On Sat, Nov 11, 2006 at 01:59:40PM -0800, Keith Goodman wrote:
> Would it make sense to upcast instead of downcast?
>
> This upcasts:
>
> >> x = M.matrix([[1, M.nan, 3]])
> >> x
> matrix([[ 1. , nan, 3. ]])
>
> But this doesn't:
>
> >> x = M.matrix([[1, 2, 3]])
> >> x[0,1] = M.nan
> >> x
> matrix([[1, 0, 3]])
This behaviour is consistent with
x = N.array([[1,2.0,3]])
vs
x = N.array([1,2,3])
x[0,1] = 2.
> (BTW, how do you represent missing integers if you can't use NaN?)
I think masked arrays should work on integer arrays (alternatively, if
you have enough memory, cast your array to float).
Regards
Stéfan
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
More information about the Numpy-discussion
mailing list