Iterating over the cells of an array?
Alex Martelli
aleax at aleax.it
Sun May 12 10:38:38 EDT 2002
Fernando Pérez wrote:
...
> ravel is I believe a copy operation, much more expensive than a call to
Chacking isn't all that expensive, is it?
>>> x=Numeric.array([range(n,n+4) for n in range(3)])
>>> x
array([[0, 1, 2, 3],
[1, 2, 3, 4],
[2, 3, 4, 5]])
>>> f=Numeric.ravel(x)
>>> f
array([0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5])
>>> x[1,1]=111
>>> x
array([[ 0, 1, 2, 3],
[ 1, 111, 3, 4],
[ 2, 3, 4, 5]])
>>> f
array([ 0, 1, 2, 3, 1, 111, 3, 4, 2, 3, 4, 5])
>>>
Alex
More information about the Python-list
mailing list