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

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

2011-10-18 Thread Matthew Brett
Hi, 2011/10/18 Frédéric Bastien no...@nouiz.org: 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

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 courn...@gmail.com wrote: On 10/12/11, V. Armando Solé s...@esrf.fr 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

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 charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett matthew.br...@gmail.com 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

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

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é s...@esrf.fr 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

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

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 David Cournapeau
On 10/12/11, V. Armando Solé s...@esrf.fr 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

[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

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 matthew.br...@gmail.comwrote: 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

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 charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi, I recently ran into this: In [68]: arr = np.array(-128, np.int8) In [69]: arr Out[69]: array(-128, dtype=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 charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett matthew.br...@gmail.com 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

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 matthew.br...@gmail.comwrote: Hi On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi, I recently ran into this:

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 ben.r...@ou.edu wrote: On Tue, Oct 11, 2011 at 2:51 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Oct 11, 2011 at 12:23 PM, Matthew Brett

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, josef.p...@gmail.com wrote: On Tue, Oct 11, 2011 at 7:13 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Oct 11, 2011 at 2:51 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi On Tue, Oct 11, 2011 at 3:16 PM, Charles R Harris