Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed issue that was causing initial conditions from being messed up …
Browse files Browse the repository at this point in the history
…when calling .run() multiple times in the same session, which screwed up the tests. Tests work again
  • Loading branch information
MintoDA1 authored and MintoDA1 committed Oct 2, 2023
1 parent 44b4b91 commit f539e26
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions swiftest/simulation_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,15 +412,16 @@ def run(self,dask: bool = False, **kwargs):
if len(kwargs) > 0:
self.set_parameter(**kwargs)

# Write out the current parameter set before executing run
self.save(verbose=False)

if self.codename != "Swiftest":
warnings.warn(f"Running an integration is not yet supported for {self.codename}",stacklevel=2)
return

# Save initial conditions
if not self.restart:
self.clean()

# Write out the current parameter set before executing run
self.write_param(verbose=False,**kwargs)

print(f"Running a {self.codename} {self.integrator} run from tstart={self.param['TSTART']} {self.TU_name} to tstop={self.param['TSTOP']} {self.TU_name}")

Expand Down
3 changes: 2 additions & 1 deletion tests/test_swiftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def test_integrators(self):

# Add the modern planets and the Sun using the JPL Horizons Database.
sim.add_solar_system_body(major_bodies)
sim.clean()

# Add 10 user-defined test particles.
ntp = 10
Expand All @@ -103,7 +104,6 @@ def test_integrators(self):
integrators= ["whm","helio","rmvs","symba"]
for i in integrators:
try:
sim.clean()
sim.run(integrator=i)
except:
self.fail(f"Failed with integrator {i}")
Expand Down Expand Up @@ -213,4 +213,5 @@ def test_gr(self):


if __name__ == '__main__':
os.environ["HDF5_USE_FILE_LOCKING"]="FALSE"
unittest.main()

0 comments on commit f539e26

Please sign in to comment.