Skip to content

Commit

Permalink
fixes #113
Browse files Browse the repository at this point in the history
  • Loading branch information
spjuhel committed Oct 8, 2024
1 parent 36266fc commit ceda1cd
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions boario/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ def __init__(
save_records: list | str = [],
boario_output_dir: str | pathlib.Path = tempfile.mkdtemp(prefix="boario"),
results_dir_name: Optional[str] = None,
show_progress: bool = True,
) -> None:
"""A Simulation instance can be initialized with the following parameters:
Expand Down Expand Up @@ -171,6 +172,8 @@ def __init__(
An optional directory where to save files generated by the simulation. Defaults to a temporary directory prefixed by "boario".
results_dir_name : str, default 'results'
The name of the folder where simulation results will be stored.
show_progress: bool, default: True
If True, shows a progress bar in the console during the simulation.
"""
self.output_dir = pathlib.Path(boario_output_dir)
Expand All @@ -197,6 +200,7 @@ def __init__(
self._save_params = save_params
self._save_index = save_index
self._register_stocks = register_stocks
self._show_progress = show_progress

# Pre-init record variables
self._production_evolution = np.array([])
Expand Down Expand Up @@ -321,7 +325,7 @@ def __init__(
f"Simulation parameters:\n{pformat(formatted_params_dict, compact=True)}"
)

def loop(self, progress: bool = True):
def loop(self):
r"""Launch the simulation loop.
This method launch the simulation for the number of steps to simulate
Expand All @@ -330,11 +334,6 @@ def loop(self, progress: bool = True):
parameters used in the logs just before running the loop. Once the loop
is completed, it flushes the different memmaps generated.
Parameters
----------
progress: bool, default: True
If True, shows a progress bar of the loop in the console.
"""
logger.info(
f"Starting model loop for at most {self.n_temporal_units_to_sim // self.model.n_temporal_units_by_step + 1} steps"
Expand All @@ -359,7 +358,8 @@ def loop(self, progress: bool = True):
).open("w") as ffile:
event_dicts = [ev.event_dict for ev in self.all_events]
json.dump(event_dicts, ffile, indent=4, cls=CustomNumpyEncoder)
if progress:

if self._show_progress:
widgets = [
"Processed: ",
progressbar.Counter("Step: %(value)d"),
Expand Down

0 comments on commit ceda1cd

Please sign in to comment.