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 wrote: > On 2012/09/21 12:20 PM, Nathaniel Smith wrote: > > On Fri, Sep 21, 2012 at 10:04 PM, Chris Barker > wrote: > >> On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith > wrote: > >> > >>> You're right of course. What I meant is that > >>>a +=

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 wrote: >> On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith wrote: >> >>> You're right of course. What I meant is that >>>a += b >>> should produce the same result as >>>a[...] = a + b >>> >>>

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 wrote: > On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith 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

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 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 results if

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

2012-09-21 Thread Nathaniel Smith
On 21 Sep 2012 17:31, "Chris Barker" wrote: > > On Thu, Sep 20, 2012 at 2:48 PM, Nathaniel Smith 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

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 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 should't work at al

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 wrote: > > > 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

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 wrote: > > > 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

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

2012-09-18 Thread Charles R Harris
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 way. Ch

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

2012-09-18 Thread Charles R Harris
On Tue, Sep 18, 2012 at 5:02 PM, Travis Oliphant wrote: > >> >> >>> 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 >>>

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

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 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 wrote: >> >>> >>> On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: >>> >>> >>> >>> On

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 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 wrote: >> >>> >>> On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: >>> >>> >>> >>> O

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 wrote: > > > On Tue, Sep 18, 2012 at 2:33 PM, Travis Oliphant wrote: > >> >> On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: >> >> >> >> On Tue, Sep 18, 2012 at 1:35 PM, Benjamin Root wrote: >> >>> >>> >>> On Tue, Sep 18, 2012 at 3:25 PM, Ch

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 wrote: > > On Sep 18, 2012, at 2:44 PM, Charles R Harris wrote: > > > > On Tue, Sep 18, 2012 at 1:35 PM, Benjamin Root wrote: > >> >> >> On Tue, Sep 18, 2012 at 3:25 PM, Charles R Harris < >> charlesr.har...@gmail.com> wrote: >> >>> >>> >>> On Tue,

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 wrote: > > > On Tue, Sep 18, 2012 at 3:25 PM, Charles R Harris > wrote: > > > On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root wrote: > > > On Tue, Sep 18, 2012 at 2:47 PM, Charles

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 > wrote: > > > > On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris > mailto:charlesr.har...@gmail.com>> wrote: > > > > On Tue, Sep 18, 2012 at 11:39 AM, Benja

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 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 wrote: >> >>> >>> >>> On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris < >>> charlesr.har

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 wrote: > > > On Tue, Sep 18, 2012 at 1:13 PM, Benjamin Root 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 wrote: >>>

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 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 wrote: >> >>> >>> >>> On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris < >>> charlesr.ha

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 wrote: > > > On Tue, Sep 18, 2012 at 9:13 PM, Benjamin Root 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 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 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 wrote: >> >>> >>> >>> On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris < >>> charlesr.ha

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

2012-09-18 Thread Benjamin Root
On Tue, Sep 18, 2012 at 2:47 PM, Charles R Harris wrote: > > > On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root 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 wrote: >>> >>>

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 wrote: > > On Sep 18, 2012, at 1:47 PM, Charles R Harris wrote: > > > > On Tue, Sep 18, 2012 at 11:39 AM, Benjamin Root wrote: > >> >> >> On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris < >> charlesr.har...@gmail.com> wrote: >> >>> >>> >>> On Mon

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 wrote: > > > On Mon, Sep 17, 2012 at 9:33 PM, Charles R Harris > wrote: > > > On Mon, Sep 17, 2012 at 3:40 PM, Travis Oliphant wrote: > > On Sep 17, 2012, at 8:42 AM, Benjamin Roo

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 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 wrote: >> >>> >>> On Sep 17, 2012, at 8:42 AM, Benjamin Root wrote: >>> >>> > Consider t

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 wrote: > > > On Mon, Sep 17, 2012 at 3:40 PM, Travis Oliphant wrote: > >> >> 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) >>

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 wrote: > > 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,

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 abou

[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 o