[Numpy-discussion] Fix for ticket #1973

Bruce Southey bsouthey@gmail....
Mon Jan 16 09:37:57 CST 2012


On 01/14/2012 04:31 PM, Charles R Harris wrote:
> I've put up a pull request for a fix to ticket #1973. Currently the 
> fix simply propagates the maskna flag when the *.astype method is 
> called. A more complicated option would be to add a maskna keyword to 
> specify whether the output is masked or not or propagates the type of 
> the source, but that seems overly complex to me.
>
> Thoughts?
>
> Chuck
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
Thanks for the correction and as well as the fix. While it worked for 
integer and floats (not complex ones), I got an error when using complex 
dtypes. This error that is also present in array creation of complex 
dtypes. Is this known or a new bug?

If it is new, then we need to identify what functionality should handle 
np.NA but are not working.

Bruce

$ python
Python 2.7 (r27:82500, Sep 16 2010, 18:02:00)
[GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> import numpy as np
 >>> np.__version__ # pull request version
'2.0.0.dev-88f9276'
 >>> np.array([1,2], dtype=np.complex)
array([ 1.+0.j,  2.+0.j])
 >>> np.array([1,2, np.NA], dtype=np.complex)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib64/python2.7/site-packages/numpy/core/numeric.py", line 
1445, in array_repr
     ', ', "array(")
   File "/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.py", 
line 459, in array2string
     separator, prefix, formatter=formatter)
   File "/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.py", 
line 263, in _array2string
     suppress_small),
   File "/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.py", 
line 724, in __init__
     self.real_format = FloatFormat(x.real, precision, suppress_small)
ValueError: Cannot construct a view of data together with the 
NPY_ARRAY_MASKNA flag, the NA mask must be added later
 >>> ca=np.array([1,2], dtype=np.complex, maskna=True)
 >>> ca[1]=np.NA
 >>> ca
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/usr/lib64/python2.7/site-packages/numpy/core/numeric.py", line 
1445, in array_repr
     ', ', "array(")
   File "/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.py", 
line 459, in array2string
     separator, prefix, formatter=formatter)
   File "/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.py", 
line 263, in _array2string
     suppress_small),
   File "/usr/lib64/python2.7/site-packages/numpy/core/arrayprint.py", 
line 724, in __init__
     self.real_format = FloatFormat(x.real, precision, suppress_small)
ValueError: Cannot construct a view of data together with the 
NPY_ARRAY_MASKNA flag, the NA mask must be added later
 >>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120116/b40cb3fb/attachment.html 


More information about the NumPy-Discussion mailing list