Re: [Numpy-discussion] Behavior of array scalars
by Sasha other posts by this author
Feb 17 2006 3:44PM messages near this date
Re: [Numpy-discussion] Behavior of array scalars
|
Re: [Numpy-discussion] Behavior of array scalars
On 2/17/06, Travis Oliphant <oliphant@[...].edu> wrote:
> ...
> Perhaps what is going on is that
> a += 10
> is begin translated to
> a = a + 10
> rather than
> add(a,10,a)
> I'll have to look deeper to see why.
It is actually being translated to "a = add(a,10,a)" by virtue of
array_inplace_add supplied in the inplace_add slot. Here is the
proof:
> >> a = array(0)
> >> a = b = array(0)
> >> a += 10
> >> b
array(10)
> >> a
10
Another way to explain it is to note that a += 10 is equivalent to "a
= a.__iadd__(10)" and a.__iadd__(10) is equivalent to "add(a, 10, a)".
This is not easy to fix because the real culprit is
> >> a = array(0)
> >> type(a) is type(a+a)
False
Maybe we can change ufunc logic so that when the output argument is
supplied it is returned without scalar conversion.
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd_______________________________________________
Numpy-discussion mailing list
Numpy-discussion@[...].net
https://lists.sourceforge.net/lists/listinfo/numpy-discussion
Thread:
Christopher Barker
Travis Oliphant
Sasha
Travis Oliphant
Christopher Barker
Sasha
Travis Oliphant
David M. Cooke
Sasha
Travis Oliphant
Travis Oliphant
Sasha
Travis Oliphant
Sasha
Alexander Belopolsky
Sasha
|