From ef394ae4c9df4b6e8d200caa78dfcea1bfde9e69 Mon Sep 17 00:00:00 2001 From: Andrew Giuliani Date: Fri, 19 Apr 2024 15:43:38 -0400 Subject: [PATCH] fix for unit tests --- .github/workflows/tests.yml | 2 +- tests/mhd/test_spec.py | 72 ++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 38 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 637981a4c..0711af9a9 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -163,7 +163,7 @@ jobs: - name: Install simsopt package # run: env CMAKE_BUILD_TYPE=Debug pip install -v .[MPI,SPEC] - run: pip install -v ".[MPI,SPEC,VIS]" + run: pip install -v ".[MPI,SPEC]" - name: Verify that importing simsopt does not automatically initialize MPI run: ./tests/verify_MPI_not_initialized.py diff --git a/tests/mhd/test_spec.py b/tests/mhd/test_spec.py index 0ab5fb536..08f0aa668 100755 --- a/tests/mhd/test_spec.py +++ b/tests/mhd/test_spec.py @@ -138,29 +138,28 @@ def test_set_profile_non_cumulative(self): filename = os.path.join(TEST_DIR, 'RotatingEllipse_Nvol8.sp') - with ScratchDir("."): - s = Spec(filename) - nvol = s.inputlist.nvol - mvol = nvol + s.inputlist.lfreebound + s = Spec(filename) + nvol = s.inputlist.nvol + mvol = nvol + s.inputlist.lfreebound - cumulative = False # Surfaces currents are non-cumulative quantities in SPEC - surface_current = ProfileSpec(np.zeros((mvol,)), cumulative=cumulative) + cumulative = False # Surfaces currents are non-cumulative quantities in SPEC + surface_current = ProfileSpec(np.zeros((mvol,)), cumulative=cumulative) - s.interface_current_profile = surface_current + s.interface_current_profile = surface_current - # Check that all currents are actually zero - for lvol in range(1, mvol): - self.assertEqual(s.get_profile('interface_current', lvol), 0) + # Check that all currents are actually zero + for lvol in range(1, mvol): + self.assertEqual(s.get_profile('interface_current', lvol), 0) - # Modify one interface current - s.set_profile('interface_current', lvol=3, value=1) + # Modify one interface current + s.set_profile('interface_current', lvol=3, value=1) - # Check values - for lvol in range(1, mvol): - if lvol != 3: - self.assertEqual(s.get_profile('interface_current', lvol), 0) - else: - self.assertEqual(s.get_profile('interface_current', lvol), 1) + # Check values + for lvol in range(1, mvol): + if lvol != 3: + self.assertEqual(s.get_profile('interface_current', lvol), 0) + else: + self.assertEqual(s.get_profile('interface_current', lvol), 1) def test_set_profile_cumulative(self): """ @@ -170,31 +169,30 @@ def test_set_profile_cumulative(self): filename = os.path.join(TEST_DIR, 'RotatingEllipse_Nvol8.sp') - with ScratchDir("."): - s = Spec(filename) - nvol = s.inputlist.nvol - mvol = nvol + s.inputlist.lfreebound + s = Spec(filename) + nvol = s.inputlist.nvol + mvol = nvol + s.inputlist.lfreebound - cumulative = True # Surfaces currents are non-cumulative quantities in SPEC - volume_current = ProfileSpec(np.zeros((mvol,)), cumulative=cumulative) + cumulative = True # Surfaces currents are non-cumulative quantities in SPEC + volume_current = ProfileSpec(np.zeros((mvol,)), cumulative=cumulative) - s.volume_current_profile = volume_current + s.volume_current_profile = volume_current - # Check that all currents are actually zero - for lvol in range(1, mvol): - self.assertEqual(s.get_profile('volume_current', lvol), 0) + # Check that all currents are actually zero + for lvol in range(1, mvol): + self.assertEqual(s.get_profile('volume_current', lvol), 0) - # Modify one interface current - s.set_profile('volume_current', lvol=3, value=1) + # Modify one interface current + s.set_profile('volume_current', lvol=3, value=1) - print(s.volume_current_profile) + print(s.volume_current_profile) - # Check values - for lvol in range(1, mvol): - if lvol < 3: - self.assertEqual(s.get_profile('volume_current', lvol), 0) - else: - self.assertEqual(s.get_profile('volume_current', lvol), 1) + # Check values + for lvol in range(1, mvol): + if lvol < 3: + self.assertEqual(s.get_profile('volume_current', lvol), 0) + else: + self.assertEqual(s.get_profile('volume_current', lvol), 1) def test_integrated_stellopt_scenarios_1dof(self): """