Skip to content

Commit 49dbf27

Browse files
committed
Adding Ak.Form type return
1 parent 4429239 commit 49dbf27

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

servicex_analysis_utils/file_peeking.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def parse_jagged_depth_and_dtype(dtype_str):
212212
return depth, None
213213

214214

215-
def str_to_array(encoded_json_str):
215+
def str_to_array(encoded_json_str, return_form=False):
216216
"""
217217
Helper to reconstruct ak.Arrays from a JSON-formatted file-structure string.
218218
Returns an array mimicking TTrees and TBranches with correct field names and dtypes.
@@ -251,7 +251,10 @@ def str_to_array(encoded_json_str):
251251
if branches:
252252
reconstructed_data[treename] = ak.Array([branches])
253253

254-
return ak.Array(reconstructed_data).type
254+
if return_form:
255+
return ak.Array(reconstructed_data).layout.form
256+
else:
257+
return ak.Array(reconstructed_data).type
255258

256259

257260
def get_structure(datasets, array_out=False, **kwargs):
@@ -274,7 +277,7 @@ def get_structure(datasets, array_out=False, **kwargs):
274277
for sample, path in output.items():
275278
with uproot.open(path[0]) as f:
276279
structure_str = f["servicex"]["branch"].array()[0]
277-
sample_array = str_to_array(structure_str)
280+
sample_array = str_to_array(structure_str, **kwargs)
278281
all_arrays[sample] = sample_array
279282
return all_arrays
280283

0 commit comments

Comments
 (0)