Replies: 1 comment 1 reply
-
You need to make the ak.Array regular (or just use a NumPy array, which are all regular). The Fixed-length lists are a different type from variable-length lists. In your descriptor, the " When you construct an ak.Array from Python data, it is all variable-length because Python lists don't have fixed lengths. >>> varlen = ak.Array([[[1, 1, 1], [2, 2, 2]], [[4, 4, 4], [5, 5, 5]]])
>>> varlen
<Array [[[1, 1, 1], [2, 2, ... 4], [5, 5, 5]]] type='2 * var * var * int64'> Note the " When you construct an ak.Array from a NumPy array, it's all regular-length because NumPy dimensions have fixed lengths. >>> reglen = ak.Array(np.array([[[1, 1, 1], [2, 2, 2]], [[4, 4, 4], [5, 5, 5]]]))
>>> reglen
<Array [[[1, 1, 1], [2, 2, ... 4], [5, 5, 5]]] type='2 * 2 * 3 * int64'> Note the " You can also turn variable-length dimensions into fixed-length dimensions with ak.to_regular (there's also an ak.from_regular). >>> ak.to_regular(varlen, axis=1)
<Array [[[1, 1, 1], [2, 2, ... 4], [5, 5, 5]]] type='2 * 2 * var * int64'>
>>> ak.to_regular(ak.to_regular(varlen, axis=1), axis=2)
<Array [[[1, 1, 1], [2, 2, ... 4], [5, 5, 5]]] type='2 * 2 * 3 * int64'> Another mismatch is the numeric type: " It looks like you want mixed variable-length and regular-length: the only way to do that is with an Awkward Array. (Python lists will be interpreted as all-variable and NumPy arrays are all-regular.) |
Beta Was this translation helpful? Give feedback.
-
I am trying to use uproot to replicate the structure of data that is currently being written in root. Each leaf has 3 integers.
The when opened in uproot the branch has a typename
uint16_t[][3]
and interpretationAsJagged(AsDtype("('>u2', (3,))"))
and I can read the data as expected. However, I cannot figure how to write such a tree with uproot. I couldn't find anything in the uproot documentation that addresses this. This is what I tried so far.Beta Was this translation helpful? Give feedback.
All reactions