[Numpy-discussion] Re: Using Reduce with Multi-dimensional Masked array

Sue Giller sag at hydrosphere.com
Thu Nov 29 15:21:04 CST 2001


Paul,

Well, you're right.  I did misunderstand your reply, as well as what 
the various functions were supposed to do.  I was mis-using the 
sum, minimum, maximum as tho they were MA.<op>.reduce, and 
my test case didn't point out the difference.  I should always have 
been doing the .reduce version.

I apologize for this!

I found a section on page 45 of the Numerical Python text (PDF 
form, July 13, 2001) that defines sum as
   'The sum function is a synonym for the reduce method of the add 
ufunc.  It returns the sum of all the elements in the sequence given 
along the specified axis (first axis by default).'

This is where I would expect to see a caveat about it not retaining 
any mask-edness.

I was misussing the MA.minimum and MA.maximum as tho they 
were .reduce version.  My bad.

The MA.average does produce a masked array, but it has changed 
the 'missing value' to fill_value=[ 1.00000002e+020,]).  I do find this 
a bit odd, since the other reductions didn't change the fill value.

Anyway, I can now get the stats I want in a format I want, and I 
understand better the various functions for array/masked array.

Thanks for the comments/input.

sue




More information about the Numpy-discussion mailing list