Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-28 Thread Chris.Barker
Keith Goodman wrote: Interestingly, MATLAB (v7.5.0) takes a different approach: ans = 1271 -A ans = 127 -1 can anyone explain that? -- just curious. Charles R Harris wrote: We could simply define the range of int8 as [-127,127], but that is somewhat problematical also. That

Re: [Numpy-discussion] Binary ufuncs: minimum

2008-05-28 Thread Charles R Harris
On Wed, May 28, 2008 at 1:08 AM, Chris.Barker [EMAIL PROTECTED] wrote: Keith Goodman wrote: Interestingly, MATLAB (v7.5.0) takes a different approach: ans = 1271 -A ans = 127 -1 can anyone explain that? -- just curious. Charles R Harris wrote: We could simply define the

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 proposal

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') But yes, that

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] mailto:[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]:

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] mailto:[EMAIL PROTECTED] wrote: Stéfan van der Walt wrote: Did this change recently? In

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] mailto:[EMAIL PROTECTED] wrote: Stéfan van der Walt wrote: Did this change recently? In

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] mailto:[EMAIL PROTECTED] wrote:

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

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 to

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 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 for signed

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 do it. I

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, -128], dtype=int8)

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] mailto:[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,

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 unsigned

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 really want

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 expectation just

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

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 is

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 expectation just

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 different type