Skip to content

Commit

Permalink
fixed unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
smiet committed Sep 6, 2023
1 parent aa64c0b commit 5314b7b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
12 changes: 7 additions & 5 deletions src/simsopt/geo/surfacerzfourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,10 +230,10 @@ def from_other_surface(cls, other: "SurfaceRZFourier", **kwargs):
nfp = kwargs.pop("nfp", other.nfp)
stellsym = kwargs.pop("stellsym", other.stellsym)

otherntheta = other.quadpoints_theta.size
othernphi = other.quadpoints_phi.size
otherntheta = other.quadpoints_theta.size
othernphi = other.quadpoints_phi.size

#recalculate the quadpoints if necessary (grid_range is not stored in the
# 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)
if ntheta is not otherntheta and nphi is not othernphi and grid_range is not None:
Expand All @@ -242,14 +242,16 @@ def from_other_surface(cls, other: "SurfaceRZFourier", **kwargs):
else:
kwargs["quadpoints_phi"] = other.quadpoints_phi
kwargs["quadpoints_theta"] = other.quadpoints_theta

surf = cls(mpol=mpol, ntor=ntor, nfp=nfp, stellsym=stellsym,
# create new surface in old resolution
surf = cls(mpol=other.mpol, ntor=other.ntor, nfp=nfp, stellsym=stellsym,
**kwargs)
surf.rc[:, :] = other.rc
surf.zs[:, :] = other.zs
if not other.stellsym:
surf.rs[:, :] = other.rs
surf.zc[:, :] = other.zc

Check warning on line 252 in src/simsopt/geo/surfacerzfourier.py

View check run for this annotation

Codecov / codecov/patch

src/simsopt/geo/surfacerzfourier.py#L251-L252

Added lines #L251 - L252 were not covered by tests
# set to the requested resolution
surf.change_resolution(mpol, ntor)
surf.local_full_x = surf.get_dofs()
return surf

Expand Down
7 changes: 3 additions & 4 deletions tests/geo/test_surface_rzfourier.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,12 +670,11 @@ def test_surface_from_other_surface_with_different_resolution(self):
s.zs[1, 0] = 0.2
s.local_full_x = s.get_dofs()

s2 = SurfaceRZFourier.from_other_surface(s, mpol=3, ntor=2, range='field period )
s2 = SurfaceRZFourier.from_other_surface(s, mpol=3, ntor=2, range='field period')
s3 = SurfaceRZFourier.from_other_surface(s2, nfp=4, ntheta=100, nphi=100, range='half period')
s4 = SurfaceRZFourier.from_other_surface(s3, nfp=s1.nfp, range='full period')
s4 = SurfaceRZFourier.from_other_surface(s3, nfp=s.nfp, range='full torus')
self.assertAlmostEqual(s.area(), s4.area(), places=4)
self.assertAlmostEqual(s.volume(), s2.volume(), places=3)

self.assertAlmostEqual(s.volume(), s4.volume(), places=3)

def test_shared_dof_serialization(self):
import tempfile
Expand Down

0 comments on commit 5314b7b

Please sign in to comment.