On Thursday 24 January 2008 15:58:14 Stefan van der Walt wrote: > How about masking the output where the condition is masked? > I.e. keep where condition is True, remove where condition is False and > mask where condition is masked.
Won't systematically do, check one of the examples I gave in a previous emails. >>>a=masked_array([1,2,3,4,5],mask=[0,0,1,1,0]) >>>a.compress((a<4).filled(True)) masked_array(data = [1 2 -- --], mask = [False False True True], fill_value=999999) Fundamentally, it's a very bad idea to use a masked array as a condition: what should be done when the condition is masked ? Here, we're going against one of the basic principles of Paul Dubois, the original author: we are making assumptions about the masked values of the condition when we consider the condition as a ndarray. In timeseries, we prevent the use of masked arrays as conditions. That's not much of a problem, as we already overloading __getitem__ to a rather ugly extent. I'm a bit reluctant to introduce that feature in numpy.ma, as it would crash the performance. That's something we may want to consider when we'll port numpy.ma to C: a masked condition is undefined, therefore cannot be used in selecting array elements, therefore should be set to False. _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
