[Numpy-discussion] Behavior of array scalars

Travis Oliphant oliphant at ee.byu.edu
Fri Feb 17 16:05:01 CST 2006

Sasha wrote:

>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

I think we do need to fix something.  Because the problem is even more 
apparent when you in-place add
an array to a matrix.


a = rand(5,5)
b = mat(a)

a += b

What do you think the type of a now is?  What should it be?

Currently,  this code would change a from an array to a matrix because

add(a,b,a) returns a matrix.

I'm thinking that we should establish the rule that if output arrays are 
given, then what is returned should just be those output arrays...

This seems to make consistent sense and it will make the inplace 
operators work as expected (not changing the type).  We are currently 
not letting in-place operators change the data-type.  Our argument 
against that behavior is weakened if we do let them change the Python 


More information about the Numpy-discussion mailing list