[Numpy-discussion] Indexing with callables (was: Yorick-like functionality)

Pauli Virtanen pav@iki...
Sat May 16 04:41:12 CDT 2009

Fri, 15 May 2009 16:09:08 -0400, David Huard wrote:
> Can this indexing syntax do things that are otherwise awkward with the
> current syntax ? Otherwise, I'm not warm to the idea of making indexing
> more complex than it is.

I think the indexing with callables is more syntax sugar for nested
`func(v, axis=n)` than anything else. It may be more useful interactive 
use than calling the functions, though. Compare:

	mean(sum(x, axis=1), axis=1)

It might be useful also for broadcasting functions operating on 1D 
vectors to the whole array, but here the semantics start getting muddier.

> getv
> drop_last
> append_one
> zcen

These, apart from zcen, were just some demo functions I pulled out from 

The actual list of Yorick functions relevant here appears to be here:


I must say that I don't see many functions missing in Numpy...

David (Strozzi): are these the functions you meant? Are there more?

Pauli Virtanen

More information about the Numpy-discussion mailing list