[PYTHON MATRIX-SIG] Re: take() again

Jim Hugunin hugunin@mit.edu
Thu, 22 Aug 1996 11:32:56 -0400


Carlos Fonseca wrote:
...
> One could always write take(a,[indices]) to get the current behaviour with
> axis=2, if indices is 1d. More generally, one could write
> 
> take( a[(ni-1)*(NewAxis,)],indices[(Ellipses,)+ax*(NewAxis,)+(All,)] )

You aren't seriously suggesting that people write python code that looks
like this?

I think that everybody could be made happy if I added the following
function to alpha3:

permute(a, permutation)

a and permutation must be aligned for as many axes as there are in
permutation.  The elements of a will be resorted according to the
elements of permutation.

ie. permute(a, argsort(a)) <==> sort(a)

I think that with this function and take almost everything that you want
to do with Carlos' fancy take would be possible.  I also think that
having two fairly easy to understand functions is a better situation
than having one really complicated one.

Note:
permute(a, indices) <==> take(a, indices)
	iff:	len(indices) = len(a)
		len(indices.shape) = 1

Opinions? - Jim

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================