Neal Becker wrote:
> This is a bit confusing to me:
>
> import numpy as np
>
> u = np.ones ((3,3))
>
> for u_row in u:
> u_row = u_row * 2 << doesn't work
>
>
Try this instead:
for u_row in u:
u_row[:] = u_row * 2
Warren
> print u
> [[ 1. 1. 1.]
> [ 1. 1. 1.]
> [ 1. 1. 1.]]
>
> for u_row in u:
> u_row *= 2 << does work
> [[ 2. 2. 2.]
> [ 2. 2. 2.]
> [ 2. 2. 2.]]
>
> Naively, I'm thinking a *= b === a = a * b.
>
> Is this behavior expected? I'm asking because I really want:
>
> u_row = my_func (u_row)
>
> _______________________________________________
> NumPy-Discussion mailing list
> [email protected]
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion