-
Notifications
You must be signed in to change notification settings - Fork 32
advanced restart options #1112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
advanced restart options #1112
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -431,7 +431,7 @@ def test_advanced_restarts_options(self): | |
| dup( | ||
| dict( | ||
| cells=10, | ||
| time_step_nbr=10, | ||
| time_step_nbr=7, | ||
| max_nbr_levels=1, | ||
| refinement="tagging", | ||
| ) | ||
|
|
@@ -440,22 +440,30 @@ def test_advanced_restarts_options(self): | |
|
|
||
| simput["interp_order"] = interp | ||
| time_step = simput["time_step"] | ||
| time_step_nbr = simput["time_step_nbr"] | ||
|
|
||
| timestamps = time_step * np.arange(time_step_nbr + 1) | ||
| timestamps = time_step * np.arange(simput["time_step_nbr"] + 1) | ||
| local_out = self.unique_diag_dir_for_test_case(f"{out}/test", ndim, interp) | ||
| simput["restart_options"]["dir"] = local_out | ||
| simput["restart_options"]["keep_last"] = 3 | ||
| simput["restart_options"]["timestamps"] = timestamps | ||
| simput["restart_options"]["restart_time"] = "auto" | ||
|
|
||
| ph.global_vars.sim = None | ||
| ph.global_vars.sim = ph.Simulation(**simput) | ||
| setup_model() | ||
| Simulator(ph.global_vars.sim).run().reset() | ||
| self.register_diag_dir_for_cleanup(local_out) | ||
|
|
||
| # restarted | ||
| timestamps = time_step * np.arange(7, 11) | ||
| simput["time_step_nbr"] = 3 | ||
| simput["restart_options"]["restart_time"] = "auto" | ||
| self.assertEqual(0.01, ph.restarts.restart_time(simput["restart_options"])) | ||
| simput["restart_options"]["timestamps"] = timestamps | ||
| self.assertEqual(0.007, ph.restarts.restart_time(simput["restart_options"])) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Potential floating-point fragility in
Suggested fix- self.assertEqual(0.007, ph.restarts.restart_time(simput["restart_options"]))
+ self.assertAlmostEqual(0.007, ph.restarts.restart_time(simput["restart_options"]))Similarly on line 479: - self.assertEqual(0.01, ph.restarts.restart_time(simput["restart_options"]))
+ self.assertAlmostEqual(0.01, ph.restarts.restart_time(simput["restart_options"]))🤖 Prompt for AI Agents
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a legit comment @PhilipDeegan we should probably check the abs(time-0.007) is less than 1e-15 or something. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ph.global_vars.sim = None | ||
| ph.global_vars.sim = ph.Simulation(**simput) | ||
| setup_model() | ||
| Simulator(ph.global_vars.sim).run().reset() | ||
|
|
||
| dirs = [] | ||
| for path_object in Path(local_out).iterdir(): | ||
|
|
@@ -469,6 +477,8 @@ def test_advanced_restarts_options(self): | |
| for i, idx in enumerate(range(8, 11)): | ||
| self.assertAlmostEqual(dirs[i], time_step * idx) | ||
|
|
||
| self.assertEqual(0.01, ph.restarts.restart_time(simput["restart_options"])) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same remark here
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's possible, but the tests are also passing, so it would be weird if they suddently stopped
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a comment why we expect binary == |
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
Uh oh!
There was an error while loading. Please reload this page.