Re: [Numpy-discussion] write access through iterator

2011-06-22 Thread Mark Wiebe
You can do something pretty close to that with the 1.6 iterator: >>> u = np.arange(20).reshape(5,4)[:,:3] >>> u array([[ 0, 1, 2], [ 4, 5, 6], [ 8, 9, 10], [12, 13, 14], [16, 17, 18]]) >>> for item in np.nditer(u, [], ['readwrite'], order='C'): ... item[...] =

[Numpy-discussion] write access through iterator

2011-06-22 Thread Neal Becker
Maybe I'm being dense today, but I don't see how to iterate over arrays with write access. You could read through iterators like: fl = u.flat >>> for item in fl: ... print item but you can't do for item in fl: item = 10 (or, it won't do what you want). Is there any way to do this? ___