[Numpy-discussion] Response to PEP suggestions
barrett at stsci.edu
Fri Feb 18 06:56:19 CST 2005
Perry Greenfield wrote:
> On Feb 17, 2005, at 3:25 PM, Travis Oliphant wrote:
>> This is basically new behavior that numarray has started supporting.
>> I just think numarray missed an important case of flattened indexing
>> that MATLAB supports. My current proposal would distinguish between
>> single-index array cases and tuple-index array cases.
>> I'm still thinking about the X.flat possibility. Basically, I think
>> that direction would requires a new "generic array view" or something
>> like that. It may be worth trying, but I'm not sure I want to go
>> that direction right now until I convince more people to come on
>> board with Numeric3.
> It was new behavior in the sense that Numeric didn't support
> multidimensional array takes and puts at the time. For a long time it
> was the only kind of array indexing IDL supported (1-d and implicit
> .flat of multidimensional arrays). Speaking only for myself, I found
> the .flat semantics more often as unwanted behavior than convenient.
> I'd rather keep the numarray behavior in this case and make the .flat
> case explicit (but I understand the difficulty of that approach).
> There is the possibility of a custom index option (but ugly I suppose)
> X[K, flatten]
> where flatten is a special object that indexing recognizes as
> signaling a different interpretation to indexing.
+1 on Travis's suggestion of X.flat[K] behavior, since I think it is
explicit and intuitive.
- 1 on X[K. flatten]
I think in the long term that the X.flat[K] proposal should be pursued,
even for non-contiguous arrays. Since we have decided that slice-as-view
behavior is the default, then I believe the user should not have to
worry whether the internal structure of an array is continguous or not.
Paul Barrett, PhD Space Telescope Science Institute
Phone: 410-338-4475 ESS/Science Software Branch
FAX: 410-338-4767 Baltimore, MD 21218
More information about the Numpy-discussion