From 8cefb7fc1ad85534e7d4ad3b45e0188782259bde Mon Sep 17 00:00:00 2001 From: DONNOT Benjamin Date: Fri, 27 Oct 2023 16:37:43 +0200 Subject: [PATCH] force the seed in some broken tests --- lightsim2grid/tests/test_dist_slack_backend.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lightsim2grid/tests/test_dist_slack_backend.py b/lightsim2grid/tests/test_dist_slack_backend.py index 966c0ea..02382ae 100644 --- a/lightsim2grid/tests/test_dist_slack_backend.py +++ b/lightsim2grid/tests/test_dist_slack_backend.py @@ -91,14 +91,20 @@ def test_after_reset(self): _ = self.env_ds.reset() self._prepare_env(self.env_ds) self._aux_test_different(self.env_ss, self.env_ds) - + + def _aux_get_kwargs_runner(self): + return dict(nb_episode=1, max_iter=self.max_iter_real, add_detailed_output=True, seed=0) + def test_after_runner(self): """test I can use the runner""" runner_ss = Runner(**self.env_ss.get_params_for_runner()) runner_ds = Runner(**self.env_ds.get_params_for_runner()) - res_ss = runner_ss.run(nb_episode=1, max_iter=self.max_iter_real, add_detailed_output=True) - res_ds = runner_ds.run(nb_episode=1, max_iter=self.max_iter_real, add_detailed_output=True) - assert res_ss[0][3] == res_ds[0][3], f"{res_ss[0][3]} vs {res_ds[0][3]}" # same number of steps survived + res_ss = runner_ss.run(self._aux_get_kwargs_runner()) + res_ds = runner_ds.run(self._aux_get_kwargs_runner()) + import pdb + pdb.set_trace() + if res_ss[0][3] != res_ds[0][3]: # same number of steps survived + raise RuntimeError(f"{res_ss[0][3]} vs {res_ds[0][3]}: ") assert res_ss[0][2] != res_ds[0][2] # not the same reward ep_ss = res_ss[0][-1] ep_ds = res_ds[0][-1]