simsopt
simsopt copied to clipboard
Intermittent test failure in `field/selffieldforces.py`
One of the tests in selffieldforces.py is failing intermittently. The OS is Ubuntu 24.04 LTS.
(test):~/Software/simsopt/tests$ python -m unittest field.test_selffieldforces.CoilForcesTest.test_lpcurveforces_taylor_test
test_lpcurveforces_taylor_test i: 10 deriv_est: -1331439771587072.0 deriv: -1331471069683030.5 err_new: 2.350640330919906e-05 err: 100 ratio: 2.3506403309199062e-07
test_lpcurveforces_taylor_test i: 11 deriv_est: -1331463244874752.0 deriv: -1331471069683030.5 err_new: 5.876814342171754e-06 err: 2.350640330919906e-05 ratio: 0.25000908326421445
test_lpcurveforces_taylor_test i: 12 deriv_est: -1331469113463808.0 deriv: -1331471069683030.5 err_new: 1.4692164681923558e-06 err: 5.876814342171754e-06 ratio: 0.2500021921144122
test_lpcurveforces_taylor_test i: 13 deriv_est: -1331470580631552.0 deriv: -1331471069683030.5 err_new: 3.673016182142233e-07 err: 1.4692164681923558e-06 ratio: 0.2499982992064684
test_lpcurveforces_taylor_test i: 14 deriv_est: -1331470947418112.0 deriv: -1331471069683030.5 err_new: 9.182694335905198e-08 err: 3.673016182142233e-07 ratio: 0.2500041894873854
test_lpcurveforces_taylor_test i: 15 deriv_est: -1331471039119360.0 deriv: -1331471069683030.5 err_new: 2.2954813811520498e-08 err: 9.182694335905198e-08 ratio: 0.24997906901643255
test_lpcurveforces_taylor_test i: 16 deriv_est: -1331471062024192.0 deriv: -1331471069683030.5 err_new: 5.7521629079205304e-09 err: 2.2954813811520498e-08 ratio: 0.25058634564196075
test_lpcurveforces_taylor_test i: 17 deriv_est: 220452526718976.0 deriv: -1331471069683030.5 err_new: 1.1655706471875928 err: 5.7521629079205304e-09 ratio: 202631717.12029263
F
======================================================================
FAIL: test_lpcurveforces_taylor_test (field.test_selffieldforces.CoilForcesTest.test_lpcurveforces_taylor_test)
Verify that dJ matches finite differences of J
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/mbkumar/Software/simsopt/tests/field/test_selffieldforces.py", line 310, in test_lpcurveforces_taylor_test
np.testing.assert_array_less(err_new, 0.31 * err)
File "/home/mbkumar/venv/test/lib/python3.12/site-packages/numpy/testing/_private/utils.py", line 1285, in assert_array_less
assert_array_compare(operator.__lt__, x, y, err_msg=err_msg,
File "/home/mbkumar/venv/test/lib/python3.12/site-packages/numpy/testing/_private/utils.py", line 921, in assert_array_compare
raise AssertionError(msg)
AssertionError:
Arrays are not strictly ordered `x < y`
Mismatched elements: 1 / 1 (100%)
Max absolute difference among violations: 1.16557065
Max relative difference among violations: 6.53650699e+08
x: array(1.165571)
y: array(1.783171e-09)
@mbkumar heads up that I also see occasional failures of LpCurveForce and MeanSquaredForce, which rely on BiotSavart objects in the definition, but I do not ever see failures in very rigorous Taylor tests of my equivalent functions like MixedLpCurveForce on the passive_coil_arrays branch, which don't use BiotSavart objects. However, these are slower to compute, so it would be good to fix the LpCurveForce objects or get the "Mixed" functions running much faster.