[SciPy-user] Assignment of oversize values.

Yosef Meller yosefmel at post.tau.ac.il
Sun Jul 19 08:08:55 EDT 2009


Hello all,

I found today that I can assign to an array some larger array, resulting in 
only the first values being assigned:

In [1]: from numpy import * 

In [2]: t = r_[1, 2, 3]

In [3]: tt = array([[1, 1, 1], [2, 2, 2]])

In [4]: tt
Out[4]:   
array([[1, 1, 1],
       [2, 2, 2]])

In [5]: t
Out[5]: array([1, 2, 3])

In [9]: t[t > 0] = tt

In [10]: t
Out[10]: array([1, 1, 1])

I expected this to raise an exception about shape error or something, but it 
did not. 

The NumPy documentation [1] doesn't mention this case, so I just wanted to ask 
if that's the intended behaveiour.

Thanks,
Yosef.




More information about the SciPy-User mailing list