Reputation: 11
I'm trying to use numpy-like syntax on an awkward.Array
with variable sizes in the second dimension, but it's still confusing..
In numpy i have
normals.shape # (N,3)
idcs.shape # (m,k)
normals[idcs].shape # (m,k,3)
So the entries of the idcs
2d-array are obviously used as indices for the first dimension of my normals
2d-array and keep that shape.
If I try the same with an awkward.Array
, it won't perform that numpy-trick of 'linear-indexing' or 'broadcasting' (whatever you may call it)
# awkward.Arrays here:
normals # N * 3
idcs # m * var <- variable sizes in second dimension
normals[idcs] # ERROR
# what I expected instead:
normals[idcs] # m * var * 3
EDIT: what I also thought about, is to reshape idcs
to one long index vector, use it to index the normals
2d-array like normals[idcs_vector]
and then reshape the result back to m * var * 3
by something like normals[idcs_vector].reshape((m,-1,3))
, but since awkward hasn't implemented a reshape
function, this is not easy
Upvotes: 1
Views: 83