Hi All,
x=arange(10) indices=[(1,),(2,)] x[indices] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: unsupported iterator index
But following works.
x=x.reshape(5,2) x array([[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]]) indices=[(1,0),(0,1)] x[indices] array([2, 1])
Should not the first one also work? How to convert [(1,),(2,)] to [1,2] efficiently. Thanks, Shailendra
2010/4/2 Shailendra <shailendra.vikas@gmail.com>:
x=arange(10) indices=[(1,),(2,)] x[indices] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: unsupported iterator index
I have more odd things to report (numpy 1.4.0):
b = numpy.asarray([[1, 2], [3, 4]]) b[[(0, 0)]] array([[1, 2], [1, 2]])
How does the advanced integer indicing mode work precisely? The docu (http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html#integer) says: "All sequences and scalars in the selection tuple are converted to intp indexing arrays." How can then numpy distinguish between lists and tuples? My thought is, that maybe only the lists are taken into account to calculate the broadcasting target, and tuples are handed over to the indicing step, as described in the docu. But then, it seems, that length1 items are "flattened"? Friedrich
participants (2)

Friedrich Romstedt

Shailendra