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

concatenate on indexed selections of `Table` is broken #195

Closed lukasheinrich closed 5 years ago

lukasheinrich commented 5 years ago

Hi, here's a minimal example of concatenating indexed selections of a table

a = awkward.fromiter([[0,1,3],[0,1],[6,5],[2]])
b = awkward.fromiter([[4,5,6],[7,8],[1,2],[6]])
t = awkward.Table(a = a, b = b)

print(t[[0,1]])
print(t[[2]])
print(awkward.concatenate([t[[0,1]],t[[2]]]))

I would have expected the last line to be Rows 0,1 and 2 instead I get the 2 full copies of the table t

lukasheinrich commented 5 years ago

it seems like this is a workardound

toconcat = [t[[0,1]],t[[3]]]
c = awkward.Table({c: awkward.concatenate([getattr(tt,c) for tt in toconcat]) for c in t.columns})
c.a
jpivarski commented 5 years ago

Try PR #196. Your work-around was the hint: the Table's lazily evaluated selections weren't being applied. (Its successors, RecordArray and LazySlice, will separate the functions of tabular data and lazy slicing.)