[SciPy-User] flat / nonflat array index conversion continued

Christoph Deil deil.christoph@googlemail....
Mon Mar 8 15:47:51 CST 2010

Sorry that I don't reply to the thread I started today (http://mail.scipy.org/pipermail/scipy-user/2010-March/024565.html), but I had the list in digest mode.
Anyways, Ryan suggested I use numpy.unravel_index, and indeed this does exactly what I wanted.

My question now is how I can vectorize numpy.unravel_index?
Here is what I tried:

idx = array([1,5]) # really I have 1e6 indices I want to unravel
unravel_index(idx,(2, 3)) # Doesn't work. Raises a ValueError
v_u_i = vectorize(unravel_index) # Try to vectorize it
v_u_i(idx,(2, 3)) # Doesn't work. Raises a TypeError

Thanks for you help!

More information about the SciPy-User mailing list