File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -153,7 +153,8 @@ def get_dtype(arr):
153153 return type (arr )
154154
155155def test_unwrangle (test_ids_dict , flat ):
156- result = unwrangle (list (flat .keys ()), test_ids_dict )
156+ result , failed = unwrangle (list (flat .keys ()), test_ids_dict )
157+ assert failed == 0 , f"The following fields failed to load { failed } "
157158 for key in flat .keys ():
158159 if np .issubdtype (get_dtype (result [key ]), np .floating ):
159160 assert ak .almost_equal (result [key ], flat [key ])
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ def unwrangle(
5656) -> Dict [str , ak .Array | np .ndarray ]:
5757 flat = {}
5858 ids_locations = split_location_across_ids (locations )
59+ failed_locations = []
5960 for key in ids_locations :
6061 tensorizer = IDSTensorizer (ids_dict [key ], ids_locations [key ])
6162 tensorizer .include_coordinate_paths ()
@@ -64,7 +65,11 @@ def unwrangle(
6465 # Add IDS conversion
6566 for ids_location in ids_locations [key ]:
6667 location = key + "." + ids_location .replace ("/" , "." )
67- values = tensorizer .awkward_tensorize (ids_location )
68+ try :
69+ values = tensorizer .awkward_tensorize (ids_location )
70+ except KeyError :
71+ failed_locations .append (location )
72+ continue
6873 if hasattr (values , "__getitem__" ):
6974 # Not a scalar, e.g. homogenous_time
7075 try :
@@ -73,4 +78,4 @@ def unwrangle(
7378 flat [location ] = ak .Array (values )
7479 else :
7580 flat [location ] = values
76- return flat
81+ return flat , failed_locations
You can’t perform that action at this time.
0 commit comments