Download validation/convert_rntuple.py from HWresearch/GNN4Colliders: direct link, hf CLI and curl.
- Browser
- Download file 852 Bytes
-
https://huggingface.co/HWresearch/GNN4Colliders/resolve/main/validation/convert_rntuple.py
- Command line
-
hf download hf://HWresearch/GNN4Colliders/validation/convert_rntuple.py
-
curl -L -o convert_rntuple.py https://huggingface.co/HWresearch/GNN4Colliders/resolve/main/validation/convert_rntuple.py
852 Bytes
| #!/usr/bin/env python3 | |
| """Make a temporary TTree copy for legacy Uproot versions.""" | |
| from __future__ import annotations | |
| import argparse | |
| from pathlib import Path | |
| import awkward as ak | |
| import uproot | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("source", type=Path) | |
| parser.add_argument("output", type=Path) | |
| args = parser.parse_args() | |
| with uproot.open(args.source) as root_file: | |
| tree = root_file["output"] | |
| arrays = tree.arrays(list(tree.keys()), library="ak") | |
| branch_types = { | |
| name: str(ak.type(arrays[name])).split("* ", 1)[1] for name in arrays.fields | |
| } | |
| with uproot.recreate(args.output) as root_file: | |
| root_file.mktree("output", branch_types) | |
| root_file["output"].extend(arrays) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |