@@ -212,7 +212,7 @@ def parse_jagged_depth_and_dtype(dtype_str):
212
212
return depth , None
213
213
214
214
215
- def str_to_array (encoded_json_str , return_form = False ):
215
+ def str_to_array (encoded_json_str , tree_forms = False ):
216
216
"""
217
217
Helper to reconstruct ak.Arrays from a JSON-formatted file-structure string.
218
218
Returns an array mimicking TTrees and TBranches with correct field names and dtypes.
@@ -223,7 +223,7 @@ def str_to_array(encoded_json_str, return_form=False):
223
223
Returns:
224
224
ak.Array: An array containing a dictionary of trees with branch structures and dummy typed values.
225
225
"""
226
- reconstructed_data = {}
226
+ reconstructed_file_data = {}
227
227
structure_dict = json .loads (encoded_json_str )
228
228
229
229
for treename , branch_dict in structure_dict .items ():
@@ -249,12 +249,17 @@ def str_to_array(encoded_json_str, return_form=False):
249
249
branches [branch_name ] = ak .Array ([dummy ])
250
250
251
251
if branches :
252
- reconstructed_data [treename ] = ak .Array ([branches ])
252
+ reconstructed_file_data [treename ] = ak .Array ([branches ])
253
253
254
- if return_form :
255
- return ak .Array (reconstructed_data ).layout .form
254
+ if tree_forms :
255
+ # Dictionary of each tree's RecordForm
256
+ tree_forms = {
257
+ tree : arr .layout .form for tree , arr in reconstructed_file_data .items ()
258
+ }
259
+ return tree_forms
256
260
else :
257
- return ak .Array (reconstructed_data ).type
261
+ # ak.Array type with all trees and branches
262
+ return ak .Array (reconstructed_file_data ).type
258
263
259
264
260
265
def get_structure (datasets , array_out = False , ** kwargs ):
@@ -273,13 +278,13 @@ def get_structure(datasets, array_out=False, **kwargs):
273
278
output = deliver (spec_python )
274
279
275
280
if array_out == True :
276
- all_arrays = {}
281
+ all_requests = {}
277
282
for sample , path in output .items ():
278
283
with uproot .open (path [0 ]) as f :
279
284
structure_str = f ["servicex" ]["branch" ].array ()[0 ]
280
- sample_array = str_to_array (structure_str , ** kwargs )
281
- all_arrays [sample ] = sample_array
282
- return all_arrays
285
+ ak_structure = str_to_array (structure_str , ** kwargs )
286
+ all_requests [sample ] = ak_structure
287
+ return all_requests
283
288
284
289
else :
285
290
return print_structure_from_str (output , ** kwargs )
0 commit comments