1

for some nd-array

a = np.zeros((2,5,4))

I want to slice the last dimension based on some boolean statement.

a[1,:, (True,True,True,True)].shape

however, returns (4,5) while I would expect a shape of (5,4) like from

a[1,:, :].shape

So, what's going on here?

(This behaviour only occurs when I drop the first dimension by selecting one singular slice from it.)

Usman
  • 1,983
  • 15
  • 28
forch
  • 11
  • 2
  • It's that slice in the middle of 'advanced' indices that's producing unexpected results. It's an obscure, but documented, corner of numpy indexing. – hpaulj Aug 28 '19 at 15:05

0 Answers0