Skip to content

Commit

Permalink
option for simpler execution of multi-thread processess
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristian Fossum committed May 28, 2024
1 parent cf8c5eb commit 6031f96
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ensemble/ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,9 +553,12 @@ def calc_prediction(self, input_state=None, save_prediction=None):
# Index list of ensemble members
list_member_index = list(range(self.ne))

# Run prediction in parallel using p_map
en_pred = p_map(self.sim.run_fwd_sim, list_state,
list_member_index, num_cpus=no_tot_run, disable=self.disable_tqdm)
if no_tot_run==1: # if not in parallel we use regular loop
en_pred = [self.sim.run_fwd_sim(state, member_index) for state, member_index in
tqdm(zip(list_state, list_member_index), total=len(list_state))]
else: # Run prediction in parallel using p_map
en_pred = p_map(self.sim.run_fwd_sim, list_state,
list_member_index, num_cpus=no_tot_run, disable=self.disable_tqdm)

# List successful runs and crashes
list_crash = [indx for indx, el in enumerate(en_pred) if el is False]
Expand Down

0 comments on commit 6031f96

Please sign in to comment.