Commit 1261e32c authored by Aidan Richard Wiederhold's avatar Aidan Richard Wiederhold
Browse files

Merge branch 'aiwieder/close_file' into 'master'

Close file and simplify hist_counter

See merge request !44
parents a8b118db 4d840251
Pipeline #3426192 passed with stages
in 2 minutes and 19 seconds
......@@ -26,14 +26,11 @@ def hist_to_root(job_name, check_result, output_path):
checks_with_histo = ["range", "range_nd", "range_bkg_subtracted"]
if check_result.check_type in checks_with_histo:
file_name = f"{job_name}_{check_result.check_type}_histograms.root"
file_root = uproot.recreate(join(output_path, file_name))
for key, data in check_result.tree_data.items():
hist_counter = 0
for _histo in data.get("histograms", []):
hist_counter += 1
histo_name = f"{key}/{hist_counter-1}"
file_root[histo_name] = _histo
with uproot.recreate(join(output_path, file_name)) as file_root:
for key, data in check_result.tree_data.items():
for hist_counter, _histo in enumerate(data.get("histograms", [])):
histo_name = f"{key}/{hist_counter-1}"
file_root[histo_name] = _histo
def checks_to_JSON(
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment