logo       
Bookmark and Share

Re: sum of a masked array: msg#00001

python.numeric.general

Subject: Re: sum of a masked array

Darren,
I tried your code on my system: Python 2.2 and numarray 1.0. The type error
looks like a bug in the array display code.

>>> Rx = ones((2500,2500))
>>> N = make_mask_none((2500,2500))
>>> Rx = array(Rx,mask=N)
>>> print average(Rx) ## works
[ 1. 1. 1. ..., 1. 1. 1.]
>>> s = sum(Rx)
>>> print s

Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.2/site-packages/numarray/ma/MA.py", line 742, in
__str__
return str(filled(self, f))
File "/usr/lib/python2.2/site-packages/numarray/generic.py", line 499, in
__str__
return arrayprint.array2string(self, separator=" ", style=str)
File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 188, in
array2string
separator, prefix)
File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 137, in
_array2string
data = _leading_trailing(a)
File "/usr/lib/python2.2/site-packages/numarray/arrayprint.py", line 105, in
_leading_trailing
b = _gen.concatenate((a[:_summaryEdgeItems],
File "/usr/lib/python2.2/site-packages/numarray/generic.py", line 1028, in
concatenate
return _concat(arrs)
File "/usr/lib/python2.2/site-packages/numarray/generic.py", line 1012, in
_concat
dest = arrs[0].__class__(shape=destShape, type=convType)
TypeError: __init__() got an unexpected keyword argument 'type'

but the array is fine

>>> for i in range(2500):
... assert s[i] == 2500
>>>

Hopefully someone with more knowledge can help you out. I still use MA with
Numeric for the most part.
--
Stephen Pitts
smpitts@xxxxxx



-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise