From 8dee6dc2a40c81ccb827a8473698ff722882031d Mon Sep 17 00:00:00 2001 From: Chris Date: Tue, 30 Jul 2024 17:36:01 +0200 Subject: [PATCH] cover surfacecopy cases --- src/simsopt/geo/surfacerzfourier.py | 9 +++++---- tests/geo/test_surface_rzfourier.py | 2 ++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/simsopt/geo/surfacerzfourier.py b/src/simsopt/geo/surfacerzfourier.py index 2b9a301dd..f816a9898 100644 --- a/src/simsopt/geo/surfacerzfourier.py +++ b/src/simsopt/geo/surfacerzfourier.py @@ -438,8 +438,11 @@ def copy(self, **kwargs): """ - ntheta = kwargs.pop("ntheta", None) - nphi = kwargs.pop("nphi", None) + otherntheta = self.quadpoints_theta.size + othernphi = self.quadpoints_phi.size + + ntheta = kwargs.pop("ntheta", otherntheta) + nphi = kwargs.pop("nphi", othernphi) grid_range = kwargs.pop("range", None) mpol = kwargs.pop("mpol", self.mpol) ntor = kwargs.pop("ntor", self.ntor) @@ -448,8 +451,6 @@ def copy(self, **kwargs): quadpoints_theta = kwargs.pop("quadpoints_theta", None) quadpoints_phi = kwargs.pop("quadpoints_phi", None) - otherntheta = self.quadpoints_theta.size - othernphi = self.quadpoints_phi.size # recalculate the quadpoints if necessary (grid_range is not stored in the # surface object, so assume that if it is given, the gridpoints should be # recalculated to the specified size) diff --git a/tests/geo/test_surface_rzfourier.py b/tests/geo/test_surface_rzfourier.py index 1dc66467f..c6b41d2c6 100755 --- a/tests/geo/test_surface_rzfourier.py +++ b/tests/geo/test_surface_rzfourier.py @@ -788,6 +788,8 @@ def test_copy_method(self): s8 = s.copy(mpol=5, ntor=6) self.assertEqual(s8.mpol, 5) self.assertEqual(s8.ntor, 6) + s9 = s.copy() + s10 = s.copy(quadpoints_phi=Surface.get_phi_quadpoints(nphi=100,range='field period'), ntheta=82) class SurfaceRZPseudospectralTests(unittest.TestCase): def test_names(self):