Skip to content

Commit

Permalink
replace progress with tqdm
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhundhausen committed Jan 31, 2024
1 parent 81a9784 commit 98472c0
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 25 deletions.
8 changes: 2 additions & 6 deletions menu_tools/caching/cache_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os

import awkward as ak
from progress.bar import IncrementalBar
from tqdm import tqdm
import uproot
import vector
import yaml
Expand Down Expand Up @@ -257,13 +257,11 @@ def _ak_array_in_chunk(self, arr, chunk_array, branches):
@utils.timer("Loading objects files")
def _concat_array_from_ntuples(self):
fnames = glob.glob(self._ntuple_path)[:]
bar = IncrementalBar("Progress", max=len(fnames))

branches = [self._object + x for x in self._branches]
all_arrays = {x.removeprefix("part"): [] for x in branches}

for fname in fnames:
bar.next()
for fname in tqdm(fnames):
new_array = {x.removeprefix("part"): [] for x in branches}

# Read files in chunks to avoid issues with large size files
Expand All @@ -282,8 +280,6 @@ def _concat_array_from_ntuples(self):
# Concatenate array from "fname file" to all_arrays
all_arrays = self._ak_array_in_chunk(all_arrays, new_array, branches)

bar.finish()

if self._object.startswith("part"):
all_arrays = {**all_arrays, **self._ref_part_iso}
if len(all_arrays) > 1:
Expand Down
7 changes: 2 additions & 5 deletions menu_tools/object_performance/plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import matplotlib.pyplot as plt
import mplhep as hep
import numpy as np
from progress.bar import IncrementalBar
from tqdm import tqdm

from menu_tools.object_performance.turnon_collection import TurnOnCollection
from menu_tools.object_performance.config import PerformancePlotConfig
Expand Down Expand Up @@ -475,9 +475,7 @@ def run(self):
for test_obj in plot_config.test_object_instances:
scalings[str(test_obj)] = {}
thds = self._get_scaling_thresholds(cfg_plot, test_obj)
bar = IncrementalBar("Progress", max=len(thds))
for threshold in thds:
bar.next()
for threshold in tqdm(thds):
turnon_collection = TurnOnCollection(cfg_plot, threshold)
turnon_collection.create_hists()
scaling_pct = turnon_collection.cfg_plot.scaling_pct
Expand All @@ -495,7 +493,6 @@ def run(self):
scaling_function_params[str(test_obj)] = params
# Write scalings for test_obj to file for usage in rate part
self._write_scalings_to_file(test_obj, params)
bar.finish()

plotter = ScalingPlotter(
plot_name,
Expand Down
2 changes: 0 additions & 2 deletions menu_tools/utils/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,6 @@ def cuts(self) -> Optional[dict[str, list[str]]]:
_cuts["inclusive"].append(global_eta_cut)
except KeyError:
_cuts["inclusive"] = [global_eta_cut]
if not _cuts:
print(f"No cuts will be applied for {self}!")
return _cuts


Expand Down
32 changes: 21 additions & 11 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ matplotlib = "3.8.2"
mplhep = "0.3.31"
numpy = "^1.23.0"
pandas = "2.1.4"
progress = "1.6"
tqdm = "4.66.1"
pyarrow = "14.0.2"
scipy = "1.10.1"
uproot = "5.0.4"
Expand Down

0 comments on commit 98472c0

Please sign in to comment.