Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-18 Thread Matthew Brett
Hi, 2011/10/18 Frédéric Bastien : > What about a parameter that allow to select the option the user want? > it would select between uint, upcasted_int, -MAX and +MAX. This way, > at least it will be documented and user who care will have the choose. > > Personally, when the option is available, I

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-18 Thread Frédéric Bastien
What about a parameter that allow to select the option the user want? it would select between uint, upcasted_int, -MAX and +MAX. This way, at least it will be documented and user who care will have the choose. Personally, when the option is available, I would prefer the safe version, uint, but I u

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-15 Thread Matthew Brett
Hi, On Wed, Oct 12, 2011 at 8:31 AM, David Cournapeau wrote: > On 10/12/11, "V. Armando Solé" wrote: >> On 12/10/2011 10:46, David Cournapeau wrote: >>> On Wed, Oct 12, 2011 at 9:18 AM, "V. Armando Solé" wrote:   From a pure user perspective, I would not expect the abs function to retu

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-12 Thread David Cournapeau
On 10/12/11, "V. Armando Solé" wrote: > On 12/10/2011 10:46, David Cournapeau wrote: >> On Wed, Oct 12, 2011 at 9:18 AM, "V. Armando Solé" wrote: >>> From a pure user perspective, I would not expect the abs function to >>> return a negative number. Returning +127 plus a warning the first time >>

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-12 Thread Daniele Nicolodi
On 11/10/11 21:16, Charles R Harris wrote: > IIRC, matlab was said to return > +127 as abs(-128), which, if true, is quite curious. I just checked and this is indeed the case in Matlab 7.10.0 R2010a: >> abs(int8(-128)) ans = 127 Cheers, -- Daniele ___

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-12 Thread V. Armando Solé
On 12/10/2011 10:46, David Cournapeau wrote: > On Wed, Oct 12, 2011 at 9:18 AM, "V. Armando Solé" wrote: >> From a pure user perspective, I would not expect the abs function to >> return a negative number. Returning +127 plus a warning the first time >> that happens seems to me a good compromise.

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-12 Thread David Cournapeau
On Wed, Oct 12, 2011 at 9:18 AM, "V. Armando Solé" wrote: >  From a pure user perspective, I would not expect the abs function to > return a negative number. Returning +127 plus a warning the first time > that happens seems to me a good compromise. I guess the question is what's the common contex

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-12 Thread V. Armando Solé
From a pure user perspective, I would not expect the abs function to return a negative number. Returning +127 plus a warning the first time that happens seems to me a good compromise. Armando On 12/10/2011 09:46, David Cournapeau wrote: > On Tue, Oct 11, 2011 at 8:16 PM, Charles R Harris > w

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-12 Thread David Cournapeau
On Tue, Oct 11, 2011 at 8:16 PM, Charles R Harris wrote: > > > On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett > wrote: >> >> Hi, >> >> I recently ran into this: >> >> In [68]: arr = np.array(-128, np.int8) >> >> In [69]: arr >> Out[69]: array(-128, dtype=int8) >> >> In [70]: np.abs(arr) >> Out[7

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread Benjamin Root
On Tue, Oct 11, 2011 at 6:33 PM, wrote: > On Tue, Oct 11, 2011 at 7:13 PM, Benjamin Root wrote: > > On Tue, Oct 11, 2011 at 2:51 PM, Matthew Brett > > wrote: > >> > >> Hi > >> > >> On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris > >> wrote: > >> > > >> > > >> > On Tue, Oct 11, 2011 at 12:23

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread josef . pktd
On Tue, Oct 11, 2011 at 7:13 PM, Benjamin Root wrote: > On Tue, Oct 11, 2011 at 2:51 PM, Matthew Brett > wrote: >> >> Hi >> >> On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris >> wrote: >> > >> > >> > On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett >> > >> > wrote: >> >> >> >> Hi, >> >> >> >>

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread Benjamin Root
On Tue, Oct 11, 2011 at 2:51 PM, Matthew Brett wrote: > Hi > > On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris > wrote: > > > > > > On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett > > > wrote: > >> > >> Hi, > >> > >> I recently ran into this: > >> > >> In [68]: arr = np.array(-128, np.int8) >

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread Matthew Brett
Hi On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris wrote: > > > On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett > wrote: >> >> Hi, >> >> I recently ran into this: >> >> In [68]: arr = np.array(-128, np.int8) >> >> In [69]: arr >> Out[69]: array(-128, dtype=int8) >> >> In [70]: np.abs(arr) >> O

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread Matthew Brett
Hi, On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris wrote: > > > On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett > wrote: >> >> Hi, >> >> I recently ran into this: >> >> In [68]: arr = np.array(-128, np.int8) >> >> In [69]: arr >> Out[69]: array(-128, dtype=int8) >> >> In [70]: np.abs(arr) >>

Re: [Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread Charles R Harris
On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett wrote: > Hi, > > I recently ran into this: > > In [68]: arr = np.array(-128, np.int8) > > In [69]: arr > Out[69]: array(-128, dtype=int8) > > In [70]: np.abs(arr) > Out[70]: -128 > > This has come up for discussion before, but no consensus was ever r

[Numpy-discussion] abs for max negative integers - desired behavior?

2011-10-11 Thread Matthew Brett
Hi, I recently ran into this: In [68]: arr = np.array(-128, np.int8) In [69]: arr Out[69]: array(-128, dtype=int8) In [70]: np.abs(arr) Out[70]: -128 Of course, I can see why this happens, but it is still surprising, and it seems to me that it would be a confusing source of bugs, because of co