[Numpy-discussion] Status of numeric3 / scipylite / scipy_core
perry at stsci.edu
Thu Mar 17 09:50:20 EST 2005
Before I delve too deeply into what you are suggesting (or asking), has
the idea to have a slice be equivalent to an index array been changed.
For example, I recall seeing (I forget where), the suggestion that
X[:,ind] is the same as X[arange(X.shape), ind]
The following seems to be at odds with this. The confusion of mixing
slices with index arrays led me to just not deal with them in numarray.
I thought index arrays were getting complicated enough. I suppose it
may be useful, but I would be good to give some motivating, realistic
examples of why they are useful. For example, I can think of lots of
motivating examples for:
using more than one index array (e.g., X[ind1, ind2])
allowing index arrays to have arbitrary shape
allowing partial indexing with index arrays
Though I'm not sure I can think of good examples of arbitrary
combinations of these capabilities (though the machinery allows it). So
one question is there a good motivating example for
X[:, ind]? By the interpretation I remember (maybe wrongly), I'm not
sure I know where that would be commonly used (it would suggest that
all the sizes of the sliced dimensions must have consistent lengths
which doesn't seem typical. Any one have good examples?
On Mar 17, 2005, at 1:32 AM, Travis Oliphant wrote:
> Travis Oliphant wrote:
>> - Where there is more than one index array, what should replace the
>> single-axis subspaces that the indexes are referencing? Remember,
>> all of the single-axis subspaces are being replaced with one "global"
>> subspace. The current proposal states that this indexing subspace
>> should be placed first and the "remaining subspaces" pasted in at the
>> Is this acceptable, or can someone see a problem??
> Answering my own question...
> I think that it makes sense to do a direct subspace replacement
> whenever the indexing arrays are right next to each other. In other
> words, I would just extend the "one-index array" rule to
> "all-consecutive-index-arrays" where of course one index array
> satisfies the all-consecutive requirement.
> Hence in the previous example:
> X[:,ind1,ind2,:,:] would result in a (10,2,3,4,40,50) with the
> (20,30)-subspace being replaced by the (2,3,4) indexing subspace.
> result[:,i,j,k,:,:] = X[:,ind1[i,j,k],ind2[i,j,k],:,:]
> Any other thoughts. (I think I will implement this initially by just
> using swapaxes on the current implementation...)
More information about the NumPy-Discussion