scikit-hep / awkward-0.x

Manipulate arrays of complex data structures as easily as Numpy.
BSD 3-Clause "New" or "Revised" License
215 stars 39 forks source link

Potential bug with subsequent masking #236

Closed mverzett closed 4 years ago

mverzett commented 4 years ago

I found out that the following sequence raises an exception:

vv = awkward.fromiter([[1.],[]])
mask = np.array([False, True])
idx = awkward.fromiter([[]])
vv[mask]
# <JaggedArray [[]] at 0x7fa8fb5e2350>
vv[mask][idx]
# *** IndexError: index 0 is out of bounds for axis 0 with size 0

Is that supposed to happen? How should I treat this?

jpivarski commented 4 years ago

I don't see that error message; I see it complaining about

TypeError: jagged index must be boolean (mask) or integer (fancy indexing)

which is to say that the empty list is assumed to have floating point type and you can't use that as an index.

NumPy casts empty lists as np.float64, but maybe Awkward should cast them as np.int64 to avoid exactly this problem. It's clear what you mean.

mverzett commented 4 years ago

Thanks!