···10101111 up_start_time = time.time()
1212 up_tree = uproot.open(file_name)[tree_name]
1313- for branch in up_tree.keys():
1414- # print(branch, up_tree[branch].typename)
1515- if up_tree[branch].typename != "std::string":
1616- up_values = up_tree[branch].array(library="np")
1717- print(f"Uproot read {branch} into a {type(up_values)} and it has a mean of {np.nanmean(up_values):.2f}")
1313+ for branch in up_tree:
1414+ # print(branch, branch.typename)
1515+ if branch.typename != "std::string": # Uproot cannot read strings?
1616+ up_values = branch.array(library="np")
1717+ print(f"Uproot read {branch.name} into a {type(up_values)} and it has a mean of {np.nanmean(up_values):.2f}")
1818 up_end_time = time.time()
19192020 print("\n")
21212222 oxy_start_time = time.time()
2323- oxy_branches = oxyroot.read_root(file_name, tree_name=tree_name)
2424- for branch in oxy_branches:
2525- oxyroot.read_root(file_name, tree_name=tree_name, branch=branch)
2626- oxy_values = oxyroot.read_root(file_name, tree_name=tree_name, branch=branch)
2323+ oxy_tree = oxyroot.open(file_name)[tree_name]
2424+ for branch in oxy_tree:
2525+ # print(branch, branch.typename)
2626+ # if branch.typename != "string":
2727+ oxy_values = branch.array()
2728 if type(oxy_values) is np.ndarray:
2828- print(f"Oxyroot read {branch} into a {type(oxy_values)} and it has a mean of {np.nanmean(oxy_values):.2f}")
2929+ print(f"Oxyroot read {branch.name} into a {type(oxy_values)} and it has a mean of {np.nanmean(oxy_values):.2f}")
2930 else:
3030- print(f"Oxyroot read {branch} into a {type(oxy_values)} and it has a length of {len(oxy_values)}")
3131+ print(f"Oxyroot read {branch.name} into a {type(oxy_values)} and it has a length of {len(oxy_values)}")
3132 oxy_end_time = time.time()
32333334 print("\n Total time")
+3-2
python/tests/test_read_from_uproot.py
···11-import pytest
21import oxyroot
32import uproot
43import numpy as np
54import os
55+66+print(oxyroot.__version__)
6778def test_read_from_uproot():
89 # Create a dummy ROOT file for testing
···1516 f["tree1"].extend({"branch1": input})
161717181818- output = oxyroot.read_root(file_name, tree_name="tree1", branch="branch1")
1919+ output = oxyroot.open(file_name)["tree1"]["branch1"].array()
1920 assert(type(output) is np.ndarray)
2021 assert(np.array_equal(input, output))
2122