Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 8:14 PM, Keith Goodman <[EMAIL PROTECTED]> wrote: > On Tue, May 27, 2008 at 4:27 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > > On Tue, May 27, 2008 at 5:39 PM, Christopher Barker > > <[EMAIL PROTECTED]> wrote: > >> > >> I'm not so sure. I know I wouldn't expect to get a di

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Keith Goodman
On Tue, May 27, 2008 at 4:27 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > On Tue, May 27, 2008 at 5:39 PM, Christopher Barker > <[EMAIL PROTECTED]> wrote: >> >> I'm not so sure. I know I wouldn't expect to get a different type back >> with a call to abs(). Do we really want to change that expectati

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Nathan Bell
On Tue, May 27, 2008 at 7:08 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > > 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

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 6:08 PM, Christopher Barker <[EMAIL PROTECTED]> 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 i

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Christopher Barker
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 int

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 5:27 PM, Nathan Bell <[EMAIL PROTECTED]> wrote: > On Tue, May 27, 2008 at 5:39 PM, Christopher Barker > <[EMAIL PROTECTED]> wrote: > > > > I'm not so sure. I know I wouldn't expect to get a different type back > > with a call to abs(). Do we really want to change that expec

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 4:39 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Travis E. Oliphant wrote: > > Yes, it does make sense to me for abs to use an unsigned type for > integers. > > I'm not so sure. I know I wouldn't expect to get a different type back > with a call to abs(). Do we real

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Nathan Bell
On Tue, May 27, 2008 at 5:39 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > > I'm not so sure. I know I wouldn't expect to get a different type back > with a call to abs(). Do we really want to change that expectation just > for the case of MIN_INT? > > While everyone is going to want an unsig

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Christopher Barker
Travis E. Oliphant wrote: > Yes, it does make sense to me for abs to use an unsigned type for integers. I'm not so sure. I know I wouldn't expect to get a different type back with a call to abs(). Do we really want to change that expectation just for the case of MIN_INT? While everyone is going

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Travis E. Oliphant
Charles R Harris wrote: > > > On Tue, May 27, 2008 at 4:07 PM, Christopher Barker > <[EMAIL PROTECTED] > wrote: > > Charles R Harris wrote: > > > Yep, abs fails: > > > > In [1]: abs(array([-128,-128], dtype=int8)) > > Out[1]: array([-128, -128], dtype=

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 4:12 PM, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On Tue, May 27, 2008 at 4:07 PM, Christopher Barker <[EMAIL PROTECTED]> > wrote: > >> Charles R Harris wrote: >> >> > Yep, abs fails: >> > >> > In [1]: abs(array([-128,-128], dtype=int8)) >> > Out[1]: array([-128, -

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 4:11 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > > > > > 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 d

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 4:07 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: > > > Yep, abs fails: > > > > In [1]: abs(array([-128,-128], dtype=int8)) > > Out[1]: array([-128, -128], dtype=int8) > > Well, yes, but this is a know vagary of the the hardware implementation

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Travis E. Oliphant
> > 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. I actually appreciate what you are doing. Obviously the segfaults are bugs.

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Nathan Bell
On Tue, May 27, 2008 at 5:07 PM, Christopher Barker <[EMAIL PROTECTED]> wrote: > > Sure, it could be fixed in this case by promoting to a larger type, but > it's going to fail at the largest integer anyway, and I don't think any > expects abs() to return a new type. > I think he was advocating usi

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Christopher Barker
Charles R Harris wrote: > Yep, abs fails: > > In [1]: abs(array([-128,-128], dtype=int8)) > Out[1]: array([-128, -128], dtype=int8) Well, yes, but this is a know vagary of the the hardware implementation for signed integers, as demonstrated by that JAVA Puzzles video that Jon Wright pointed us

Re: [Numpy-discussion] Is this a bug?

2008-05-27 Thread Travis E. Oliphant
Robert Kern wrote: > > > Can we make it so that dtype('c') is preserved instead of displaying > '|S1'? It does not behave the same as dtype('|S1') although it > compares equal to it. > We could with some special-casing in the representation for string data-types. Right now, dtype('c') is equ

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Christopher Barker
Charles R Harris wrote: > 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. FWIW, I'm glad you're doing it! -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Res

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 3:28 PM, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On Tue, May 27, 2008 at 2:40 PM, Travis E. Oliphant < > [EMAIL PROTECTED]> wrote: > >> Charles R Harris wrote: >> > >> > >> > On Tue, May 27, 2008 at 2:10 PM, Travis E. Oliphant >> > <[EMAIL PROTECTED]

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 2:40 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: > > > > > > On Tue, May 27, 2008 at 2:10 PM, Travis E. Oliphant > > <[EMAIL PROTECTED] > wrote: > > > > Stéfan van der Walt wrote: > > > Did this change recent

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 2:40 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: > > > > > > On Tue, May 27, 2008 at 2:10 PM, Travis E. Oliphant > > <[EMAIL PROTECTED] > wrote: > > > > Stéfan van der Walt wrote: > > > Did this change recent

Re: [Numpy-discussion] Current ufunc signatures for review

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 2:52 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Tue, May 27, 2008 at 2:53 PM, Travis E. Oliphant > <[EMAIL PROTECTED]> wrote: > > Charles R Harris wrote: > > >> 2) Complex divmod(), // and % are deprecated, should we make them > >> raise errors? > > Sometimes you have

Re: [Numpy-discussion] complex arithmetic (floor)

2008-05-27 Thread Alan G Isaac
Reason for deprecation might be exposed by this? http://mail.python.org/pipermail/python-dev/2007-January/070794.html> PEP 3141 discusses this obliquely in the discussion of the Number ABC: http://www.python.org/dev/peps/pep-3141/> Until NumPy can justify its choice with reference to either Pyth

Re: [Numpy-discussion] Is this a bug?

2008-05-27 Thread Robert Kern
On Tue, May 27, 2008 at 3:15 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: >> >> On Tue, May 27, 2008 at 1:31 PM, Travis E. Oliphant >> <[EMAIL PROTECTED] > wrote: >> >> Charles R Harris wrote: >> > I vaguely recall this generated an a

Re: [Numpy-discussion] Current ufunc signatures for review

2008-05-27 Thread Robert Kern
On Tue, May 27, 2008 at 2:53 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: >> 2) Complex divmod(), // and % are deprecated, should we make them >> raise errors? > Sometimes you have float data that is complex because of an intermediate > calculation. I don't think w

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Travis E. Oliphant
Charles R Harris wrote: > > > On Tue, May 27, 2008 at 2:10 PM, Travis E. Oliphant > <[EMAIL PROTECTED] > wrote: > > Stéfan van der Walt wrote: > > Did this change recently? > > > > In [33]: np.__version__ > > Out[33]: '1.1.0.dev5211' > > > > In

Re: [Numpy-discussion] Possible errors in type promotion in binary ufuncs

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 2:02 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: > > Attached as a zip file. The mailing list is still stuck in the > > microzone, 40kb limit. > > The type promotion rules are the same for all the ufuncs. I'm not sure > what the value is in

Re: [Numpy-discussion] Current ufunc signatures for review

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 1:53 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: > > Hi All, > > > > Here is the current behavior of the ufuncs and some comments. They > > don't yet cover mixed types for binary functions, > > but when they do we will see things like: > > >

Re: [Numpy-discussion] Is this a bug?

2008-05-27 Thread Travis E. Oliphant
Charles R Harris wrote: > > > On Tue, May 27, 2008 at 1:31 PM, Travis E. Oliphant > <[EMAIL PROTECTED] > wrote: > > Charles R Harris wrote: > > I vaguely recall this generated an array from all the characters. > > > > In [1]: array('123', dtype='c') >

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 2:10 PM, Travis E. Oliphant <[EMAIL PROTECTED]> 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') > >

Re: [Numpy-discussion] Is this a bug?

2008-05-27 Thread Charles R Harris
On Tue, May 27, 2008 at 1:31 PM, Travis E. Oliphant <[EMAIL PROTECTED]> wrote: > Charles R Harris wrote: > > I vaguely recall this generated an array from all the characters. > > > > In [1]: array('123', dtype='c') > > Out[1]: > > array('1', > > dtype='|S1') > This may be a bug. > > >>> imp

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-27 Thread Travis E. Oliphant
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

Re: [Numpy-discussion] Possible errors in type promotion in binary ufuncs

2008-05-27 Thread Travis E. Oliphant
Charles R Harris wrote: > Attached as a zip file. The mailing list is still stuck in the > microzone, 40kb limit. The type promotion rules are the same for all the ufuncs. I'm not sure what the value is in going over each binary ufunc one-by-one.The behavior is based on how ufuncs are fou

Re: [Numpy-discussion] Current ufunc signatures for review

2008-05-27 Thread Travis E. Oliphant
Charles R Harris wrote: > Hi All, > > Here is the current behavior of the ufuncs and some comments. They > don't yet cover mixed types for binary functions, > but when they do we will see things like: > > In [7]: power(True,10) > Out[7]: > array([ 0.5822807 , 0.66568381, 0.11748811, 0.97047323,

Re: [Numpy-discussion] Is this a bug?

2008-05-27 Thread Travis E. Oliphant
Charles R Harris wrote: > I vaguely recall this generated an array from all the characters. > > In [1]: array('123', dtype='c') > Out[1]: > array('1', > dtype='|S1') This may be a bug. >>> import Numeric >>> Numeric.array('123','c') array([1, 2, 3],'c') My memory of the point of 'c' was t