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

Accumulate numpy arrays inside the loop #257

Closed EnginEren closed 3 years ago

EnginEren commented 3 years ago

Dear colleagues,

I'm sorry beforehand if this question has been asked already.. Or the answer is hidden in the tutorials. I have tried my best to find an answer but could not find it.

Just imagine you have an event loop and getting information one by one

for i in event:
    x = i.getPositionX()
    e = i.getEnergy()
    ## would like to accumulate these information 

Instead of appending the information to python lists, I would like to append them into Jagged / numpy arrays inside the loop.

Cheers, Engin

jpivarski commented 3 years ago

I see that this went to Awkward 1. My answer there (https://github.com/scikit-hep/awkward-1.0/issues/500#issuecomment-718104095) applies equally to Awkward 0 except for the Numba part. Numba is only (correctly/fully) implemented in Awkward 1.