Skip to content

Commit

Permalink
more unit tests for code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewgiuliani committed May 6, 2024
1 parent 069c5f7 commit c9d729b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/geo/test_boozersurface.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,27 @@ def subtest_boozer_serialization(self, label):
# check that BoozerSurface.surface and label.surface are the same surfaces
assert bs_regen.label.surface is bs_regen.surface

def test_run_code(self):
"""
This unit test verifies that the run_code portion of the BoozerSurface class is working as expected
"""
bs, boozer_surface = get_boozer_surface(boozer_type='ls')
boozer_surface.run_code('ls', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False)

# this second time should not actually run
boozer_surface.run_code('ls', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False)

bs, boozer_surface = get_boozer_surface(boozer_type='exact')
boozer_surface.run_code('exact', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False)

# this second time should not actually run
boozer_surface.run_code('exact', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False)

boozer_surface.need_to_run_code=True
# this should raise an exception
with self.assertRaises(Exception):
boozer_surface.run_code('', boozer_surface.res['iota'], boozer_surface.res['G'], verbose=False)

def test_convergence_cpp_and_notcpp_same(self):
"""
This unit test verifies that that the cpp and not cpp implementations converge to
Expand Down
5 changes: 5 additions & 0 deletions tests/objectives/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,8 @@ def test_mpi_optimizable(self):
mpi_surfaces = MPIOptimizable(surfaces, ["x"], comm)
for s, sx in zip(mpi_surfaces, equal_to):
np.testing.assert_allclose(s.x, sx, atol=1e-14)

# this should raise an exception
mpi_surfaces = [SurfaceXYZTensorFourier(mpol=1, ntor=1, stellsym=True) for i in range(size)]
with self.assertRaises(Exception):
_ = MPIOptimizable(surfaces, ["y"], comm)

0 comments on commit c9d729b

Please sign in to comment.