uproot5 icon indicating copy to clipboard operation
uproot5 copied to clipboard

How to create an empty tree with several var-length branches that share the var length

Open HDembinski opened this issue 1 year ago • 3 comments

I want to write several variable length arrays that have the same length to an empty tree. https://uproot.readthedocs.io/en/latest/basic.html#extending-ttrees-with-large-datasets explains

  1. How to generate an empty tree with mktree, which can be extended later, I need this
  2. How to generate a tree with several arrays that share the length and already contain data, with awkward.zip

What I am missing is the combination of the two. I want to start with an empty tree like in 1) that has branches which share the varlength. Then I want to extend this tree subsequently. Is this possible? If not, may I suggest the following intuitive API:

Instead of {"x": "var * float32", "y": "var * float32"}, which generates two extra branches "nx" and "ny", please allow this declaration, where the counting branch is explicit:

{"n": "int32", "x": "n * float32", "y": "n * float32"}

As the Python of Zen says, explicit is better than implicit.

HDembinski avatar Oct 18 '22 11:10 HDembinski