Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-21 Thread Chris Barker
On Thu, Sep 20, 2012 at 2:48 PM, Nathaniel Smith n...@pobox.com wrote: because a += b really should be the same as a = a + b. I don't think that's the case - the inplace operator should be (and are) more than syntactic sugar -- they have a different meaning and use (in fact, I think they

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-21 Thread Nathaniel Smith
On 21 Sep 2012 17:31, Chris Barker chris.bar...@noaa.gov wrote: On Thu, Sep 20, 2012 at 2:48 PM, Nathaniel Smith n...@pobox.com wrote: because a += b really should be the same as a = a + b. I don't think that's the case - the inplace operator should be (and are) more than syntactic sugar

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-21 Thread Chris Barker
On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith n...@pobox.com wrote: You're right of course. What I meant is that a += b should produce the same result as a[...] = a + b If we change the casting rule for the first one but not the second, though, then these will produce different

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-21 Thread Nathaniel Smith
On Fri, Sep 21, 2012 at 10:04 PM, Chris Barker chris.bar...@noaa.gov wrote: On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith n...@pobox.com wrote: You're right of course. What I meant is that a += b should produce the same result as a[...] = a + b If we change the casting rule for the

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-21 Thread Eric Firing
On 2012/09/21 12:20 PM, Nathaniel Smith wrote: On Fri, Sep 21, 2012 at 10:04 PM, Chris Barker chris.bar...@noaa.gov wrote: On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith n...@pobox.com wrote: You're right of course. What I meant is that a += b should produce the same result as

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-21 Thread Charles R Harris
On Fri, Sep 21, 2012 at 5:51 PM, Eric Firing efir...@hawaii.edu wrote: On 2012/09/21 12:20 PM, Nathaniel Smith wrote: On Fri, Sep 21, 2012 at 10:04 PM, Chris Barker chris.bar...@noaa.gov wrote: On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith n...@pobox.com wrote: You're right of

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-20 Thread Nathaniel Smith
On Wed, Sep 19, 2012 at 1:08 AM, Charles R Harris charlesr.har...@gmail.com wrote: snip The relevant setting is in numpy/core/include/numpy/ndarraytypes.h #define NPY_DEFAULT_ASSIGN_CASTING NPY_SAME_KIND_CASTING I think that if we want to raise a warning we could define a new rule,

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Benjamin Root
On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Sep 17, 2012 at 3:40 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 17, 2012, at 8:42 AM, Benjamin Root wrote: Consider the following code: import numpy as np a = np.array([1, 2, 3, 4,

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root ben.r...@ou.edu wrote: On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Sep 17, 2012 at 3:40 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 17, 2012, at 8:42 AM, Benjamin Root wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Travis Oliphant
On Sep 18, 2012, at 1:47 PM, Charles R Harris wrote: On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root ben.r...@ou.edu wrote: On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Sep 17, 2012 at 3:40 PM, Travis Oliphant tra...@continuum.io

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 1:08 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 18, 2012, at 1:47 PM, Charles R Harris wrote: On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root ben.r...@ou.edu wrote: On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris charlesr.har...@gmail.com wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Ralf Gommers
On Tue, Sep 18, 2012 at 9:13 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root ben.r...@ou.edu wrote: On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Benjamin Root
On Tue, Sep 18, 2012 at 3:19 PM, Ralf Gommers ralf.gomm...@gmail.comwrote: On Tue, Sep 18, 2012 at 9:13 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root ben.r...@ou.edu wrote: On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Benjamin Root
On Tue, Sep 18, 2012 at 3:25 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 1:35 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 3:25 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Eric Firing
On 2012/09/18 9:25 AM, Charles R Harris wrote: On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root ben.r...@ou.edu mailto:ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris charlesr.har...@gmail.com mailto:charlesr.har...@gmail.com wrote: On Tue, Sep

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Travis Oliphant
On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: On Tue, Sep 18, 2012 at 1:35 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 3:25 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root ben.r...@ou.edu wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 2:33 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: On Tue, Sep 18, 2012 at 1:35 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 3:25 PM, Charles R Harris charlesr.har...@gmail.com wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Benjamin Root
On Tue, Sep 18, 2012 at 4:42 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 2:33 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: On Tue, Sep 18, 2012 at 1:35 PM, Benjamin Root ben.r...@ou.edu wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Ralf Gommers
On Tue, Sep 18, 2012 at 10:52 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 4:42 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 2:33 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 2:52 PM, Benjamin Root ben.r...@ou.edu wrote: On Tue, Sep 18, 2012 at 4:42 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Tue, Sep 18, 2012 at 2:33 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote:

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Travis Oliphant
That is sort of the point of all this. We are using 16 bit integers because we wanted to be as efficient as possible and didn't need anything larger. Note, that is what we changed the code to, I am just wondering if we are being too cautious. The casting kwarg looks to be what I

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
snip The relevant setting is in numpy/core/include/numpy/ndarraytypes.h #define NPY_DEFAULT_ASSIGN_CASTING NPY_SAME_KIND_CASTING I think that if we want to raise a warning we could define a new rule, NPY_WARN_SAME_KIND_CASTING Which would do the same as unsafe, only raise a warning on the

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 6:08 PM, Charles R Harris charlesr.har...@gmail.com wrote: snip The relevant setting is in numpy/core/include/numpy/ndarraytypes.h #define NPY_DEFAULT_ASSIGN_CASTING NPY_SAME_KIND_CASTING I think that if we want to raise a warning we could define a new rule,

[Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-17 Thread Benjamin Root
Consider the following code: import numpy as np a = np.array([1, 2, 3, 4, 5], dtype=np.int16) a *= float(255) / 15 In v1.6.x, this yields: array([17, 34, 51, 68, 85], dtype=int16) But in master, this throws an exception about failing to cast via same_kind. Note that numpy was smart about this

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-17 Thread Travis Oliphant
On Sep 17, 2012, at 8:42 AM, Benjamin Root wrote: Consider the following code: import numpy as np a = np.array([1, 2, 3, 4, 5], dtype=np.int16) a *= float(255) / 15 In v1.6.x, this yields: array([17, 34, 51, 68, 85], dtype=int16) But in master, this throws an exception about failing

Re: [Numpy-discussion] Regression: in-place operations (possibly intentional)

2012-09-17 Thread Charles R Harris
On Mon, Sep 17, 2012 at 3:40 PM, Travis Oliphant tra...@continuum.iowrote: On Sep 17, 2012, at 8:42 AM, Benjamin Root wrote: Consider the following code: import numpy as np a = np.array([1, 2, 3, 4, 5], dtype=np.int16) a *= float(255) / 15 In v1.6.x, this yields: array([17, 34,