[Numpy-discussion] Response to PEP suggestions
Colin J. Williams
cjw at sympatico.ca
Thu Feb 17 17:29:23 CST 2005
Peter Verveer wrote:
> On Feb 17, 2005, at 7:52 PM, Travis Oliphant wrote:
>> I'm glad to get the feedback.
>> 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]. The problem with always requiring the use of X.flat[K] is
>> that X.flat does not work for discontiguous arrays. It could be
>> made to work if X.flat returned some kind of specially-marked array,
>> which would then have to be checked every time indexing occurred for
>> any array. Or, there maybe someway to have X.flat return an
>> "indexable iterator" for X which may be a more Pythonic thing to do
>> anyway. That could solve the problem and solve the discontiguous
>> X.flat problem as well.
> But possibly slow, and that we want to avoid.
Currently, numarray returns an array with a reduced rank:
array([[0, 1, 2],
[3, 4, 5],
[6, 7, 8]])
array([3, 4, 5])
array([1, 4, 7])
Is this to be abandoned?
More information about the Numpy-discussion