import numpy as np a = np.arange(8*6*3).reshape((8, 6, 3)) l = np.array([[0,0],[0,1],[1,1]])
Ann Archibald says
When you supply arrays in all index slots, what you get back has the same shape as the arrays that you insert; so if you are one-dimensional lists for example
A [[1,2,3], [1,4,5], [7,6,2]]
what are you getting
[A [1,1,7], A [2,4,6], A [3,5,2]]
When you compare this with your example, you see that
a[l] = b tells NumPy to install
a[0,0,1] = [0,0,5] a[0,1,1] = [0,1,0]
and the third element b not assigned. This is why you get an error message
ValueError: array is not broadcastable to correct shape
The solution is to convert the array l to the correct form:
In [50]: tuple(lT) Out[50]: (array([0, 0, 1]), array([0, 1, 1]))
(You can also use zip(*l) , but tuple(lT) bit faster.)