1

I am using uproot with awkward-array and have two jagged arrays containing the list of electrons per event and muons per event. How can I combine these to get the list of leptons per event i.e. concatenate the inner axis

E.g. I have

<JaggedArray [[30.124887 8.12566 4.782032 ... 3.4062831 4.03435 1.9781811] [19.604109 14.973876 6.788245 ... 3.8568115 2.8912365 1.643329] [94.34076 9.03234 8.532933 ... 5.3950877 5.4614944 4.3668523] ... [38.562923 12.081268 13.118397 ... 4.6826 9.002948 9.387798] [57.30162 40.492176 16.799332 ... 2.3019862 2.7607398 1.1167078] [44.25976 49.21996 25.044079 ... 2.7800367 2.2228014 1.9305638]] at 0x00013e6c5b90>

and

 <JaggedArray [[18.414927 27.532492 52.004097 171.83276 13.92745 112.39277] [39.092228 12.521418 550.6525 14.215196] [2.4486308 22.593899] ... [52.05381 2.8950057 3.3865757 ... 56.505566 8.103792 5.061536] [2.3811734 2.2230856 3.4453635 15.346841] []] at 0x00013bf7e350>

and the output I want is something like

<JaggedArray [[30.124887 8.12566 4.782032 ... 3.4062831 4.03435 1.9781811 18.414927 27.532492 52.004097 171.83276 13.92745 112.39277] [[19.604109 14.973876 6.788245 ... 3.8568115 2.8912365 1.643329 39.092228 12.521418 550.6525 14.215196] []] >

Cheers,

Carl

1 Answers1

0

What you want is awkward.concatenate with axis=1 (inner lists), as opposed to the default axis=0 (outer list).

You lose the identities of the particles—which were electrons and which were mins, but unless you apply complex filters, you can reconstruct them with the counts of the original jagged arrays.

Jim Pivarski
  • 5,568
  • 2
  • 35
  • 47
  • I should have been clearer that I am doing this with the result of zipping JaggedArrays and I get: ``` NotImplementedError: concatenate with axis=1 is not implemented for JaggedArray ``` – carl gwilliam Oct 17 '19 at 23:03
  • This is a misleading error message—it's raised inside the implementation of `concatenate` with `axis=1` for JaggedArrays: https://github.com/scikit-hep/awkward-array/blob/f1b4a3473c3eac5a1919565be4e9a0681611204b/awkward/array/jagged.py#L1707 I see your case implemented in the `if` statements above it: JaggedArrays of numbers are definitely included. Could you report a minimal reproducing example in GitHub Issues? – Jim Pivarski Oct 18 '19 at 07:15
  • Done. Thanks. https://github.com/scikit-hep/awkward-array/issues/205 – carl gwilliam Oct 18 '19 at 08:18
  • Thanks! From your example, I can see that you're not concatenating `JaggedArrays` of numbers (your original question), which `awkward.concatenate` already handles. Your case _should_ be handled, and I added a PR. (For future readers of this, follow the link above.) – Jim Pivarski Oct 18 '19 at 09:46