[Numpy-discussion] Should bool_ subclass int?

Gael Varoquaux gael.varoquaux at normalesup.org
Tue Jul 10 12:00:42 EDT 2007

On Tue, Jul 10, 2007 at 11:31:35AM -0400, Alan G Isaac wrote:
> Do you agree that the first (!!!) answer is a bug?
> (The basis is apparently performed as follows:
> integer array subtraction is first performed, and
> then nonzero ints are converted to True.  But this
> gives the wrong answer and most critically breaks
> the equivalence of a-b and a+(-b).)

OK, putting aside the useless maths, I agree that specifically having

a-b != a+(-b)

If numpy developpers agree, I think the proper solution is :

    def __sub__(self, b):
        return self.__add__(-b)

I think to should allow to have more or less consistent operations.


More information about the NumPy-Discussion mailing list