[Numpy-discussion] Deprecate boolean math operators?
njs at pobox.com
Fri Dec 6 03:24:30 EST 2013
On Thu, Dec 5, 2013 at 7:33 PM, <josef.pktd at gmail.com> wrote:
> On Thu, Dec 5, 2013 at 5:37 PM, Sebastian Berg
> <sebastian at sipsolutions.net> wrote:
>> there was a discussion that for numpy booleans math operators +,-,* (and
>> the unary -), while defined, are not very helpful. I have set up a quick
>> PR with start (needs some fixes inside numpy still):
>> The idea is to deprecate these, since the binary operators |,^,| (and
>> the unary ~ even if it is weird) behave identical. This would not affect
>> sums of boolean arrays. For the moment I saw one "annoying" change in
>> numpy, and that is `abs(x - y)` being used for allclose and working
>> nicely currently.
> I like mask = mask1 * mask2
> That's what I learned working my way through scipy.stats.distributions
> a long time ago.
* is least problematic case, since there numpy and python bools
already almost agree. (They return the same values, but numpy returns
a bool array instead of an integer array.)
On Thu, Dec 5, 2013 at 8:05 PM, Alan G Isaac <alan.isaac at gmail.com> wrote:
> For + and * (and thus `dot`), this will "fix" something that is not broken.
> It is in fact in conformance with a large literature on boolean arrays
> and boolean matrices.
Interesting point! I had assumed that dot() just upcast! But what do
you think about the inconsistency between sum() and dot() on bool
More information about the NumPy-Discussion