With the indexing example from the documentation:

y = np.arange(35).reshape(5,7)

Why does selecting an item from explicitly every row work as I’d expect:
>>> y[np.array([0,1,2,3,4]),np.array([0,0,0,0,0])]
array([ 0,  7, 14, 21, 28])

But doing so from a full slice (which, I would naively expect to mean “Every 
Row”) has some…other… behaviour:

>>> y[:,np.array([0,0,0,0,0])]
array([[ 0,  0,  0,  0,  0],
       [ 7,  7,  7,  7,  7],
       [14, 14, 14, 14, 14],
       [21, 21, 21, 21, 21],
       [28, 28, 28, 28, 28]])

What is going on in this example, and how do I get what I expect? By explicitly 
passing in an extra array with value===index? What is the rationale for this 
difference in behaviour?

Thanks,

Nick
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to