D0SBoots - 1 month ago 10

Python Question

numpy.unravel_index() takes a shape and a flat index into an array, and returns the tuple that represents that index in the array. Is there an inverse? I can compute it by hand, but this seems like it must be a built-in function somewhere...

Answer

The answer lies in numpy.ndarray.strides. See http://docs.scipy.org/doc/numpy/reference/generated/numpy.ndarray.strides.html

Source (Stackoverflow)

Comments