[Numpy-discussion] maskedarray: how to force mask to expand

Vincent Schut schut at sarvision.nl
Wed Sep 24 06:25:57 EDT 2008


Probably I'm just overlooking something obvious, but I'm having problems 
with maskedarrays (numpy.ma from svn: '1.3.0.dev5861'), the mask by 
default being a single bool value ('False') instead of a properly sized 
bool array. If I then try to mask one value by assigning values to 
certain mask positions (a.mask[0,0]=True) I get an error, logically. I 
know I can use mask_where, but I like the mask[...] idiom. And I have to 
expand the mask anyway, as I'm gonna write it to a file at the end.

1) Is there a way to have ma always use properly expanded masks (bool 
arrays instead of single bool values)? I tried the shrink=False keyword, 
but that does not do what I want, and is not available for 
numpy.ma.zeros, which I conveniently use a lot.

2) Is there a method/function to request the mask, be it a single bool 
value or an array, as a properly sized array? I found shrink_mask but no 
opposite method, and shrink_mask seems to do something subtly different 
even.

Regards,
Vincent.




More information about the NumPy-Discussion mailing list