|
From: Alexander B. <ale...@gm...> - 2006-02-17 20:50:37
|
On 2/17/06, Christopher Barker <Chr...@no...> wrote: > >>> x +=3D 5 > > I expect this to change the object in place. > > >>> x > 10 > > but what is this? is it no longer an array? I would say it is a bug, but here is an easy work-around >>> x =3D array(5) >>> id(x) 6425088 >>> x[()]+=3D5 >>> id(x) 6425088 >>> x array(10) You can also use >>> x[...]+=3D5 >>> x array(15) With an additional benefit that the same syntax works for any shape. > Is there a way to set the value in place, without resorting to: >>> x[...] =3D 10 or >>> x[()] =3D 10 You can see more on this feature at http://projects.scipy.org/scipy/numpy/wiki/ZeroRankArray |