22import awkward as ak
33import numpy as np
44from . import IDSFactory
5+ from .ids_convert import convert_ids
56from .ids_toplevel import IDSToplevel
67from .backends .netcdf .ids_tensorizer import IDSTensorizer
78
@@ -33,7 +34,7 @@ def recursively_put(location, value, ids):
3334 return ids
3435
3536
36- def wrangle (flat : Dict , source_version = "3.41.0" ) -> Dict [str , IDSToplevel ]:
37+ def wrangle (flat : Dict , source_version : str ) -> Dict [str , IDSToplevel ]:
3738 wrangled = {}
3839 factory = IDSFactory (source_version )
3940 for key in flat :
@@ -55,13 +56,18 @@ def split_location_across_ids(locations: List[str]) -> Dict[str, List[str]]:
5556
5657
5758def unwrangle (
58- locations : List [str ], ids_dict : Dict [str , IDSToplevel ], target_version = "3.41.0"
59+ locations : List [str ],
60+ ids_dict : Dict [str , IDSToplevel ],
61+ target_version : str | None = None ,
5962) -> Tuple [Dict [str , ak .Array | np .ndarray ], List [str ]]:
6063 flat = {}
6164 ids_locations = split_location_across_ids (locations )
6265 failed_locations = []
6366 for key in ids_locations :
64- tensorizer = IDSTensorizer (ids_dict [key ], ids_locations [key ])
67+ ids = ids_dict [key ]
68+ if target_version is not None :
69+ ids = convert_ids (ids , target_version )
70+ tensorizer = IDSTensorizer (ids , ids_locations [key ])
6571 tensorizer .include_coordinate_paths ()
6672 tensorizer .collect_filled_data ()
6773 tensorizer .determine_data_shapes ()
0 commit comments