From 6f189d8c8e850e092d816f6be3d6f87b4f983ac2 Mon Sep 17 00:00:00 2001 From: Arthur Goldberg Date: Thu, 17 Dec 2020 09:34:51 -0500 Subject: [PATCH] check the stop condition before simulation starts --- de_sim/simulator.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/de_sim/simulator.py b/de_sim/simulator.py index 035371d..4c435e1 100644 --- a/de_sim/simulator.py +++ b/de_sim/simulator.py @@ -638,6 +638,10 @@ def _simulate(self): self.num_handlers_called = 0 self.log_with_time(f"Simulation to {self.sim_config.max_time} starting") + # check the stop condition + if self.sim_config.stop_condition is not None and self.sim_config.stop_condition(self.time): + raise SimulatorError(f"Stop condition true at beginning of simulation at time {self.time}") + try: self.progress.start(self.sim_config.max_time) self.init_metadata_collection(self.sim_config)