[Numpy-discussion] Binary ufuncs: minimum

Charles R Harris charlesr.harris at gmail.com
Tue May 27 17:28:09 EDT 2008


On Tue, May 27, 2008 at 2:40 PM, Travis E. Oliphant <oliphant at enthought.com>
wrote:

> Charles R Harris wrote:
> >
> >
> > On Tue, May 27, 2008 at 2:10 PM, Travis E. Oliphant
> > <oliphant at enthought.com <mailto:oliphant at enthought.com>> wrote:
> >
> >     Stéfan van der Walt wrote:
> >     > Did this change recently?
> >     >
> >     > In [33]: np.__version__
> >     > Out[33]: '1.1.0.dev5211'
> >     >
> >     > In [34]: np.minimum(np.uint8(164), np.uint64(12807)).dtype
> >     > Out[34]: dtype('uint64')
> >     >
> >     > But yes, that looks like it should return a uint8.
> >     >
> >     This discussion is really moot unless a proposal for how to handle
> >     different casting rules for different ufuncs is proposed.   Right
> now,
> >     the type-promotion rules are generic and do not depend on the
> >     ufunc only
> >     on coercion rules for the mixed types.
> >
> >     One problem with a casting-rules-per-ufunc approach is that it
> >     makes it
> >     harder to add new types and have them fit in to the casting structure
> >     (which is currently possible now).   Some mechanism for allowing the
> >     types to plug-in to the per-ufunc rules would be needed.
> >
> >     These are not impossible things, just a bit of work and not on my
> >     personal priority list.
> >
> >
> > Not everything follows those rules, however. So I have put these
> > things up for review so that we can agree on what the are. Of
> > particular concern in my mind are the bitwise and shift operators
> > which currently work in a counter intuitive manner.
>
> Right now, the only complete description of the rules is the code that
> implements them.  So, from that perspective, yes everything follows
> those rules ;-)
>

So the segfaults are defined behavior? ;) It's like pulling teeth without
anesthesia to get these things defined and everyone is going to think I'm an
a-hole. It's a dirty job, but someone has got to do it.

What about abs(-128) returning a negative number for int8? Might it not be
better to return the corresponding unsigned type? Can't check that at the
moment, as I'm trying to get 64 bit Ubuntu installed on a software raid1
partition for further checks, and Ubuntu overwrote my MBR without asking.
It's a traditional Ubuntu thing.

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


More information about the NumPy-Discussion mailing list