From 62487ffbcadce7841e70fd0405984c9201e05464 Mon Sep 17 00:00:00 2001 From: Nick ODell Date: Thu, 18 Sep 2025 23:07:10 -0600 Subject: [PATCH] Exempt np.linalg.solve call from nopython mode --- process/tf_coil.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/process/tf_coil.py b/process/tf_coil.py index 92cca87391..152528eede 100644 --- a/process/tf_coil.py +++ b/process/tf_coil.py @@ -5023,8 +5023,17 @@ def plane_stress(nu, rad, ey, j, nlayers, n_radial_array): # Find solution vector cc # *** - aa = np.asfortranarray(aa) - cc = np.linalg.solve(aa, bb) + # This context manager runs the code in Python by copying the data + # out of numba, running the code, and then copying the result + # back in. This means that the linear algebra solve is not compiled and runs + # as if it were written in normal Python. + # This is necessary because numba compiles against the SciPy algebra library, + # not the Numpy one. There are differences in the Scipy solvers depending on + # operating system/architecture/Scipy version that cause tests to fail. + # https://github.com/ukaea/PROCESS/issues/3027 + # https://github.com/scipy/scipy/issues/23639 + with numba.objmode(cc="float64[:]"): + cc = np.linalg.solve(aa, bb) # Multiply c by (-1) (John Last, internal CCFE memorandum, 21/05/2013) for ii in range(nlayers):