[Numpy-discussion] Response to PEP suggestions
jswhit at fastmail.fm
Thu Feb 17 12:14:16 EST 2005
Travis Oliphant wrote:
> 2) Multidimensional array indexing.
> Sometimes it is useful to select out of an array some elements based
> on it's linear (flattened) index in the array. MATLAB, for example,
> will allow you to take a three-dimensional array and index it with a
> single integer based on it's Fortran-order: x(1,1,1), x(2,1,1), ...
> What I'm proposing would have X[K] essentially equivalent to X.flat[K].
Maybe I'm missing something, but in Numeric and Numarray right now
>>> from Numeric import *
>>> a = reshape(arange(9),(3,3))
>>> print a
[[0 1 2]
[3 4 5]
[6 7 8]]
array([3, 4, 5])
so a[K] and a.flat[K] are very different things for multidimensional
arrays. I think it would be a bad idea to change this now - it would
certainly break a lot of my code.
Or are you only talking about the case when K is a rank-1 index array
and not a scalar?
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/CDC R/CDC1 Email : Jeffrey.S.Whitaker at noaa.gov
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg
More information about the NumPy-Discussion