diff --git a/python/gvec/util/params.py b/python/gvec/util/params.py index 78c7ab9a..a68857d7 100644 --- a/python/gvec/util/params.py +++ b/python/gvec/util/params.py @@ -518,8 +518,9 @@ def two_power(xv): case "gauss_trunc": if current_density: return _gauss_legendre_integral( - lambda xv: c[0] - * (np.exp(-((xv / c[1]) ** 2)) - np.exp(-((1 / c[1]) ** 2))), + lambda xv: ( + c[0] * (np.exp(-((xv / c[1]) ** 2)) - np.exp(-((1 / c[1]) ** 2))) + ), x, ) return ( @@ -1105,7 +1106,7 @@ def bspl2gvec( def profile_from_parameters(params: CaseInsensitiveDict) -> BSpline | Polynomial: match params.get("type", "polynomial"): case "polynomial": - coefs = np.array(params["coefs"]) + coefs = np.array(params["coefs"], dtype=float) coefs *= params.get("scale", PARAMETER_SCALE_DEFAULT) return np.polynomial.Polynomial(coefs) diff --git a/test-CI/unit-pygvec/test_util.py b/test-CI/unit-pygvec/test_util.py index 025d3614..fbcac83c 100644 --- a/test-CI/unit-pygvec/test_util.py +++ b/test-CI/unit-pygvec/test_util.py @@ -557,3 +557,12 @@ def test_compute_boundary_perturbation_removes_dropped_modes_keeps_base(): assert dict(pert["X1pert_b_cos"]) == {(2, 1): -0.03} assert dict(pert["X1pert_b_sin"]) == {(1, 1): -0.01} assert dict(pert["X2pert_b_sin"]) == {} + + +def test_polynomial_profile_with_integer_coefficients(): + import numpy as np + + from gvec.util.params import profile_from_parameters + + iota = profile_from_parameters({"type": "polynomial", "coefs": [1], "scale": -1.0}) + np.testing.assert_allclose(iota(0.5), -1.0)