I was setting the fill_value as 'NA' when constructing the array so the masked values would be printed as 'NA'. It is not a big deal to avoid doing this.
Nevertheless, the differences between a masked array with a boolean mask and a mask of booleans have caused me trouble before. Especially when there are hidden in-place conversions of a mask which is a array of False to a mask which is False. e.g. import numpy print numpy.version.version ma1 = numpy.ma.array(((1.,2,3),(4,5,6)), mask=((0,0,0),(0,0,0))) print ma1.mask a1 = numpy.asarray(ma1) print ma1.mask ---------------------- 0.9.9.2538 [[False False False] [False False False]] False On 6/21/06, Pierre GM <[EMAIL PROTECTED]> wrote: > On Wednesday 21 June 2006 04:46, Michael Sorich wrote: > > When transposing a masked array of dtype '<f8' I noticed that an > > ndarray of dtype '|O4' was returned. > > > OK, I see where the problem is: > When your fill_value has a type that cannot be converted to the type of your > data, the `filled` method (used internally in many functions, such as > `transpose`) raises a TypeError, which is caught and your array is converted > to 'O'. > > That's what happen here: your fill_value is a string, your data are integer, > the types don't match, hence the conversion. So, no, I don't think that's a > bug. > > Why filling when you don't have any masked values, then ? Well, there's a > subtle difference between a boolean mask and a mask of booleans. > When the mask is boolean (mask=nomask=False), there's no masked value, and > `filled` returns the data. > Now, when your mask is an array of boolean (your first case), MA doesn't check > whether mask.any()==False to determine whether there are some missing data or > not, it just processes the whole array of boolean. > > I agree that's a bit confusing here, and there might be some room for > improvement (for example, changing the current > `if m is nomask` to `if m is nomask or m.any()==False`, or better, forcing > mask to nomask if mask.any()==False). But I don;t think that qualifies as > bug. > > In short: > when you have an array of numbers, don't try to fill it with characters. > All the advantages of Linux Managed Hosting--Without the Cost and Risk! Fully trained technicians. The highest number of Red Hat certifications in the hosting industry. Fanatical Support. Click to learn more http://sel.as-us.falkag.net/sel?cmd=lnk&kid=107521&bid=248729&dat=121642 _______________________________________________ Numpy-discussion mailing list Numpy-discussion@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/numpy-discussion