[Numpy-discussion] Deprecate boolean math operators?

josef.pktd at gmail.com josef.pktd at gmail.com
Fri Dec 6 13:35:16 EST 2013


On Fri, Dec 6, 2013 at 1:16 PM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> On 12/6/2013 12:23 PM, Alexander Belopolsky wrote:
>> What is the rationale for this:
>>
>>  >>> -array(True) + array(True)
>> True
>
>
> The minus is complementation.
> So you are just writing
>         False or True

unary versus binary minus

>>> m1 + (-m2)
array([False, False,  True,  True,  True], dtype=bool)
>>> m1 - m2
array([ True,  True, False, False,  True], dtype=bool)

>>> -m2 + m1
array([False, False,  True,  True,  True], dtype=bool)

>>> m1 - (-m2)
array([False, False,  True,  True, False], dtype=bool)

I'd rather write ~ than unary - if that's what it is.

Josef


>
> Alan Isaac
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list