[Numpy-discussion] Regression: in-place operations (possibly intentional)
Fri Sep 21 17:20:30 CDT 2012
On Fri, Sep 21, 2012 at 10:04 PM, Chris Barker <email@example.com> wrote:
> On Fri, Sep 21, 2012 at 10:03 AM, Nathaniel Smith <firstname.lastname@example.org> 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 a is integer and b is float:
> I certainly agree that we would want that, however, numpy still needs
> to deal tih pyton symantics, which means that wile (at the numpy
> level) we can control what "a[...] =" means, and we can control what
> "a + b" produces, we can't change what "a + b" means depending on the
> context of the left hand side.
> that means we need to do the casting at the assignment stage, which I
> gues is your point -- so:
> a_int += a_float
> should do the addition with the "regular" casting rules, then cast to
> an int after doing that.
> not sure the implimentation details.
Yes, that seems to be what happens.
In : a = np.arange(3)
In : a *= 1.5
In : a
Out: array([0, 1, 3])
But still, the question is, can and should we tighten up the
assignment casting rules to same_kind or similar?
More information about the NumPy-Discussion