On Fri, Dec 6, 2013 at 1:46 PM, Alan G Isaac <alan.is...@gmail.com> wrote: > On 12/6/2013 1:35 PM, josef.p...@gmail.com wrote: >> unary versus binary minus > > Oh right; I consider binary `-` broken for > Boolean arrays. (Sorry Alexander; I did not > see your entire issue.) > > >> I'd rather write ~ than unary - if that's what it is. > > I agree. So I have no objection to elimination > of the `-`. I see it does the subtraction and then > a boolean conversion, which is not helpful. > Or rather, I do not see how it can be helpful.
What I would or might find useful is if binary `-` subtracts set membership instead of doing xor >>> m1 = np.array([0,0,1,1], bool) >>> m2 = np.array([0,1,0,1], bool) >>> m1 - m2 array([False, True, True, False], dtype=bool) >>> np.logical_xor(m1, m2) array([False, True, True, False], dtype=bool) >>> np.clip(m1.astype(int) - m2.astype(int), 0, 1).astype(bool) array([False, False, True, False], dtype=bool) >>> np.nonzero(_)[0] array([2]) >>> s1 = set(np.arange(4)[m1]) >>> s2 = set(np.arange(4)[m2]) >>> s1 - s2 set([2]) Josef > > Alan Isaac > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion