diff --git a/src/iminuit/util.py b/src/iminuit/util.py index 8f62ac03..fa3b1af4 100644 --- a/src/iminuit/util.py +++ b/src/iminuit/util.py @@ -236,7 +236,7 @@ def _set(self, i: int, arg: UserBound) -> None: state.set_error(i, err) -def _normalize_limit(lim: UserBound) -> Tuple[float, float]: +def _normalize_limit(lim: Optional[Iterable]) -> Tuple[float, float]: if lim is None: return (-np.inf, np.inf) a, b = lim diff --git a/tests/test_cost.py b/tests/test_cost.py index 05a1e407..b683b621 100644 --- a/tests/test_cost.py +++ b/tests/test_cost.py @@ -1164,7 +1164,7 @@ def grad2(x, b, a): return g def model3(x, c): - return c + return c * np.ones_like(x) def grad3(x, c): return np.ones((1, len(x))) @@ -1201,7 +1201,7 @@ def grad3(x, c): a = 2 b = 3 ref = np.zeros(2) - ref[0] += lsq1.grad(a) + ref[0] += lsq1.grad(a)[0] ref[[1, 0]] += lsq2.grad(b, a) assert_allclose(lsq12.grad(a, b), ref) @@ -1214,9 +1214,9 @@ def grad3(x, c): a = 2 b = 3 ref = np.zeros(2) - ref[0] += lsq1.grad(a) + ref[0] += lsq1.grad(a)[0] ref[[1, 0]] += lsq2.grad(b, a) - ref[0] += lsq1.grad(a) + ref[0] += lsq1.grad(a)[0] assert_allclose(lsq121.grad(a, b), ref) lsq312 = lsq3 + lsq12 @@ -1229,8 +1229,8 @@ def grad3(x, c): b = 3 c = 4 ref = np.zeros(3) - ref[0] += lsq3.grad(c) - ref[1] += lsq1.grad(a) + ref[0] += lsq3.grad(c)[0] + ref[1] += lsq1.grad(a)[0] ref[[2, 1]] += lsq2.grad(b, a) assert_allclose(lsq312.grad(c, a, b), ref) diff --git a/tests/test_minimize.py b/tests/test_minimize.py index ea5d50e3..07e51d67 100644 --- a/tests/test_minimize.py +++ b/tests/test_minimize.py @@ -63,9 +63,9 @@ def rosen(par): def test_disp(capsys): - minimize(lambda x: x**2, 0) + minimize(lambda x: np.sum(x**2), 0) assert capsys.readouterr()[0] == "" - minimize(lambda x: x**2, 0, options={"disp": True}) + minimize(lambda x: np.sum(x**2), 0, options={"disp": True}) assert capsys.readouterr()[0] != "" @@ -115,7 +115,7 @@ class Fcn: def __call__(self, x): self.n += 1 - return x**2 + 1e-2 * (self.n % 3) + return np.sum(x**2 + 1e-2 * (self.n % 3)) r = minimize(Fcn(), [1], options={"maxfun": 100000000}) assert not r.success