Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dpanici committed Nov 20, 2024
1 parent 2cd1a63 commit a440353
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
3 changes: 0 additions & 3 deletions desc/objectives/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,6 @@ def __call__(self, x_reduced):
def softmax(arr, alpha):
"""JAX softmax implementation.
Inspired by https://www.johndcook.com/blog/2010/01/13/soft-maximum/
and https://www.johndcook.com/blog/2010/01/20/how-to-compute-the-soft-maximum/
Parameters
----------
arr : ndarray
Expand Down
5 changes: 3 additions & 2 deletions tests/test_objective_funs.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ def test_plasma_vessel_distance(self):
warnings.simplefilter("error")
obj.build()

# test softmin, should give value less than true minimum
# test softmin, should give approximate value
surf_grid = LinearGrid(M=5, N=6)
plas_grid = LinearGrid(M=5, N=6)
obj = PlasmaVesselDistance(
Expand All @@ -725,11 +725,12 @@ def test_plasma_vessel_distance(self):
surface_grid=surf_grid,
surface=surface,
use_softmin=True,
softmin_alpha=5,
)
obj.build()
d = obj.compute_unscaled(*obj.xs(eq, surface))
assert d.size == obj.dim_f
assert np.all(np.abs(d) < a_s - a_p)
np.testing.assert_allclose(np.abs(d).min(), a_s - a_p, rtol=1.5e-1)

# for large enough alpha, should be same as actual min
obj = PlasmaVesselDistance(
Expand Down

0 comments on commit a440353

Please sign in to comment.