From a440353baecb94354512239776b1042b89733c7a Mon Sep 17 00:00:00 2001 From: Dario Panici Date: Wed, 20 Nov 2024 11:37:04 -0500 Subject: [PATCH] fix tests --- desc/objectives/utils.py | 3 --- tests/test_objective_funs.py | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/desc/objectives/utils.py b/desc/objectives/utils.py index c257d50be..d02e70bc7 100644 --- a/desc/objectives/utils.py +++ b/desc/objectives/utils.py @@ -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 diff --git a/tests/test_objective_funs.py b/tests/test_objective_funs.py index e376eb123..b5c56cf5c 100644 --- a/tests/test_objective_funs.py +++ b/tests/test_objective_funs.py @@ -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( @@ -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(