Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename eq method to equiv to avoid confusion with Equilibrium #917

Merged
merged 1 commit into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Changelog
=========

- Adds a bounding box to the `field_line_integrate` defined by `bounds_R` and `bounds_Z` keyword arguments, which form a hollow cylindrical bounding box. If the field line trajectory exits these bounds, the RHS will be multiplied by an exponentially decaying function of the distance to the box to stop the trajectory and prevent tracing the field line out to infinity, which is both costly and unnecessary when making a Poincare plot, the principle purpose of the function.
- Renames the method for comparing equivalence between DESC objects from `eq` to `equiv`
to avoid confusion with the common shorthand for `Equilibrium`.


v0.10.4
-------
Expand Down
4 changes: 2 additions & 2 deletions desc/io/equilibrium_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def __setstate__(self, state):
if hasattr(self, "_set_up"):
self._set_up()

def eq(self, other):
def equiv(self, other):
"""Compare equivalence between DESC objects.

Two objects are considered equivalent if they will be saved and loaded
Expand All @@ -265,7 +265,7 @@ def eq(self, other):

Returns
-------
eq : bool
equiv : bool
whether this and other are equivalent
"""
if self.__class__ != other.__class__:
Expand Down
8 changes: 4 additions & 4 deletions desc/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -645,11 +645,11 @@
if basis is None:
basis = self.basis

if not self.grid.eq(grid):
if not self.grid.equiv(grid):
self._grid = grid
self._built = False
self._built_pinv = False
if not self.basis.eq(basis):
if not self.basis.equiv(basis):
self._basis = basis
self._built = False
self._built_pinv = False
Expand All @@ -666,7 +666,7 @@

@grid.setter
def grid(self, grid):
if not self.grid.eq(grid):
if not self.grid.equiv(grid):

Check warning on line 669 in desc/transform.py

View check run for this annotation

Codecov / codecov/patch

desc/transform.py#L669

Added line #L669 was not covered by tests
self._grid = grid
if self.method == "fft":
self._check_inputs_fft(self.grid, self.basis)
Expand All @@ -686,7 +686,7 @@

@basis.setter
def basis(self, basis):
if not self.basis.eq(basis):
if not self.basis.equiv(basis):
self._basis = basis
if self.method == "fft":
self._check_inputs_fft(self.grid, self.basis)
Expand Down
4 changes: 2 additions & 2 deletions desc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ def equals(a, b):
if len(a) != len(b):
return False
return all([equals(a[i], b[i]) for i in range(len(a))])
if hasattr(a, "eq"):
return a.eq(b)
if hasattr(a, "equiv"):
return a.equiv(b)
return a == b


Expand Down
2 changes: 1 addition & 1 deletion tests/test_coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def test_dunder_methods(self):
assert coils1[-2].__class__ is coil1.__class__

coils2 = CoilSet.linspaced_angular(coil1)
assert coils2[0].eq(coil1) and not (coils2[0] is coil1)
assert coils2[0].equiv(coil1) and not (coils2[0] is coil1)
coils2[0] = coil1
assert coils2[0] is coil1
with pytest.raises(TypeError):
Expand Down
8 changes: 4 additions & 4 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_defaults(self):
assert eq.M == 1
assert eq.N == 0
assert eq.sym is False
assert eq.surface.eq(FourierRZToroidalSurface(sym=False))
assert eq.surface.equiv(FourierRZToroidalSurface(sym=False))
assert isinstance(eq.pressure, PowerSeriesProfile)
assert isinstance(eq.current, PowerSeriesProfile)
np.testing.assert_allclose(eq.p_l, [0])
Expand All @@ -54,8 +54,8 @@ def test_supplied_objects(self):
sym=False,
)

assert eq.pressure.eq(pressure)
assert eq.iota.eq(iota)
assert eq.pressure.equiv(pressure)
assert eq.iota.equiv(iota)
assert eq.spectral_indexing == "ansi"
assert eq.NFP == 2
assert eq.axis.NFP == 2
Expand All @@ -65,7 +65,7 @@ def test_supplied_objects(self):

surface2 = ZernikeRZToroidalSection(spectral_indexing="ansi")
eq2 = Equilibrium(surface=surface2)
assert eq2.surface.eq(surface2)
assert eq2.surface.equiv(surface2)

surface3 = FourierRZToroidalSurface(NFP=3)
eq3 = Equilibrium(surface=surface3)
Expand Down
8 changes: 4 additions & 4 deletions tests/test_curves.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def test_misc(self):
np.testing.assert_allclose(c.Z_n, [])

s = c.copy()
assert s.eq(c)
assert s.equiv(c)

c.change_resolution(5)
assert c.N == 5
Expand Down Expand Up @@ -377,7 +377,7 @@ def test_misc(self):
np.testing.assert_allclose(c.Z_n, [-2, 3, 0])

s = c.copy()
assert s.eq(c)
assert s.equiv(c)

c.change_resolution(5)
assert c.N == 5
Expand Down Expand Up @@ -511,7 +511,7 @@ def test_misc(self):
np.testing.assert_allclose(c.normal * np.linalg.norm(c.center), c.center[::-1])

s = c.copy()
assert s.eq(c)
assert s.equiv(c)

c.change_resolution(5)
with pytest.raises(ValueError):
Expand Down Expand Up @@ -750,7 +750,7 @@ def test_misc(self):
c = SplineXYZCurve(X=R * np.cos(phi), Y=R * np.sin(phi), Z=np.zeros_like(phi))

s = c.copy()
assert s.eq(c)
assert s.equiv(c)

@pytest.mark.unit
def test_compute_ndarray_error(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_input_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def test_copy():

transform3 = transform1.copy(deepcopy=True)
assert transform1.basis is not transform3.basis
assert transform1.basis.eq(transform3.basis)
assert transform1.basis.equiv(transform3.basis)
np.testing.assert_allclose(
transform1.matrices["direct1"][0][0][0],
transform3.matrices["direct1"][0][0][0],
Expand Down Expand Up @@ -593,4 +593,4 @@ def test_save_after_load(tmpdir_factory):
# ensure can save again without an error being thrown due
# to the .h5 file not being closed
eq2.save(tmp_path)
assert eq2.eq(eq)
assert eq2.equiv(eq)
2 changes: 1 addition & 1 deletion tests/test_magnetic_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ def test_io_fourier_current_field(self):
)
field.save("test_field.h5")
field2 = load("test_field.h5")
assert field.eq(field2)
assert field.equiv(field2)

@pytest.mark.unit
def test_fourier_current_potential_field_asserts(self):
Expand Down
4 changes: 2 additions & 2 deletions tests/test_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_misc(self):
np.testing.assert_allclose(c.Z_lmn, [2])

s = c.copy()
assert s.eq(c)
assert s.equiv(c)

c.change_resolution(0, 5, 5)
with pytest.raises(ValueError):
Expand Down Expand Up @@ -393,7 +393,7 @@ def test_misc(self):
with pytest.raises(ValueError):
c.set_coeffs(0, 0, None, 2)
s = c.copy()
assert s.eq(c)
assert s.equiv(c)

c.change_resolution(5, 5, 0)
with pytest.raises(ValueError):
Expand Down
14 changes: 7 additions & 7 deletions tests/test_transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def test_eq(self):
transf_32 = Transform(grid_3, basis_2)
transf_32b = Transform(grid_3, basis_2)

assert not transf_11.eq(transf_21)
assert not transf_31.eq(transf_32)
assert transf_32.eq(transf_32b)
assert not transf_11.equiv(transf_21)
assert not transf_31.equiv(transf_32)
assert transf_32.equiv(transf_32b)

@pytest.mark.unit
def test_transform_order_error(self):
Expand Down Expand Up @@ -185,10 +185,10 @@ def test_set_grid(self):
transf_5 = Transform(grid_5, basis, method="fft")

transf_3.grid = grid_5
assert transf_3.eq(transf_5)
assert transf_3.equiv(transf_5)

transf_3.grid = grid_1
assert transf_3.eq(transf_1)
assert transf_3.equiv(transf_1)

np.testing.assert_allclose(transf_3.nodes, grid_1.nodes)

Expand All @@ -206,10 +206,10 @@ def test_set_basis(self):
transf_31 = Transform(grid, basis_31, method="fft")

transf_21.basis = basis_31
assert transf_21.eq(transf_31)
assert transf_21.equiv(transf_31)

transf_21.basis = basis_20
assert transf_21.eq(transf_20)
assert transf_21.equiv(transf_20)

np.testing.assert_allclose(transf_21.modes, basis_20.modes)

Expand Down
Loading