[Numpy-discussion] Binary ufuncs: minimum

Charles R Harris charlesr.harris at gmail.com
Tue May 27 20:27:18 EDT 2008


On Tue, May 27, 2008 at 6:08 PM, Christopher Barker <Chris.Barker at noaa.gov>
wrote:

> Charles R Harris wrote:
> > I guess it
> > depends on what guarantees we want to make, which is what this is all
> about.
>
> Exactly. However, while I'd like to guarantee that abs(x) >= 0, the
> truth is that numpy is "close to the metal" in a lot of ways, and anyone
> should know that the arithmetic of integers near max and minimum values
> is fraught with danger.
>
> If we don't change the type, then any number other than MIN_INT works
> correctly. I think more code will break by silently going from a signed
> to a signed type than that one value being weird.
>

I disagree. By definition, abs() >= 0 always. The only time having an
unsigned return will cause problems is in the augmented assignments, and
they already cause problems by not raising errors on mixed type operations,
so let the user beware.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20080527/fc8d5806/attachment.html>


More information about the NumPy-Discussion mailing list