[Numpy-discussion] Deprecate boolean math operators?

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Dec 5 23:02:34 EST 2013


On Thu, Dec 5, 2013 at 10:56 PM, Alexander Belopolsky <ndarray at mac.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.
>
> It has been suggested at the Github that there is an area where it is useful
> to have linear algebra operations like matrix multiplication to be defined
> over a semiring:
>
> http://en.wikipedia.org/wiki/Logical_matrix
>
> This still does not justify having unary or binary -, so I suggest that we
> first discuss deprecation of those.

Does it make sense to only remove - and maybe / ?

would python sum still work?   (I almost never use it.)

>>> sum(mask)
2
>>> sum(mask.tolist())
2

is accumulate the same as sum and would keep working?

>>> np.add.accumulate(mask)
array([0, 0, 0, 1, 2])


In operation with other dtypes, do they still dominate so these work?

>>> x / mask
array([0, 0, 0, 3, 4])
>>> x * 1. / mask
array([ nan,  inf,  inf,   3.,   4.])
>>> x**mask
array([1, 1, 1, 3, 4])
>>> mask - 5
array([-5, -5, -5, -4, -4])

Josef

>
> _______________________________________________
> 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