Skip to content

Commit d0cbe9d

Browse files
author
Release Manager
committed
gh-40285: Fix tests with scipy 1.16 Make tests pass with scipy 1.16: - Drop deprecated `iprint` parameter for `l-bfgs-b` algorithm. - Adapt to output changes with new COBYLA implementation. In particular, the tests in https://github.com/sagemath/sage/blob/10.7.b eta6/src/sage/numerical/optimize.py#L522-L525 give a completely different answer, which is as meaningless as the previous one since the function does not have a minimum. We mark them as random, since their only purpose is to test that it doesn't throw an error. URL: #40285 Reported by: Antonio Rojas Reviewer(s): Antonio Rojas, François Bissey, user202729
2 parents f346d6e + 094ca44 commit d0cbe9d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/sage/numerical/optimize.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,9 @@ def minimize_constrained(func, cons, x0, gradient=None, algorithm='default', **a
519519
sage: x, y = var('x y')
520520
sage: f(x,y) = (100 - x) + (1000 - y)
521521
sage: c(x,y) = x + y - 479 # > 0
522-
sage: minimize_constrained(f, [c], [100, 300])
522+
sage: minimize_constrained(f, [c], [100, 300]) # random
523523
(805.985..., 1005.985...)
524-
sage: minimize_constrained(f, c, [100, 300])
524+
sage: minimize_constrained(f, c, [100, 300]) # random
525525
(805.985..., 1005.985...)
526526
527527
If ``func`` is symbolic, its minimizer should be in the same order
@@ -532,7 +532,7 @@ def minimize_constrained(func, cons, x0, gradient=None, algorithm='default', **a
532532
sage: f(y,x) = x - y
533533
sage: c1(y,x) = x
534534
sage: c2(y,x) = 1-y
535-
sage: minimize_constrained(f, [c1, c2], (0,0))
535+
sage: minimize_constrained(f, [c1, c2], (0,0)) # abs tol 1e-04
536536
(1.0, 0.0)
537537
"""
538538
from sage.structure.element import Expression
@@ -567,12 +567,12 @@ def minimize_constrained(func, cons, x0, gradient=None, algorithm='default', **a
567567
if isinstance(cons[0], (tuple, list)) or cons[0] is None:
568568
if gradient is not None:
569569
if algorithm == 'l-bfgs-b':
570-
min = optimize.fmin_l_bfgs_b(f, x0, gradient, bounds=cons, iprint=-1, **args)[0]
570+
min = optimize.fmin_l_bfgs_b(f, x0, gradient, bounds=cons, **args)[0]
571571
else:
572572
min = optimize.fmin_tnc(f, x0, gradient, bounds=cons, messages=0, **args)[0]
573573
else:
574574
if algorithm == 'l-bfgs-b':
575-
min = optimize.fmin_l_bfgs_b(f, x0, approx_grad=True, bounds=cons, iprint=-1, **args)[0]
575+
min = optimize.fmin_l_bfgs_b(f, x0, approx_grad=True, bounds=cons, **args)[0]
576576
else:
577577
min = optimize.fmin_tnc(f, x0, approx_grad=True, bounds=cons, messages=0, **args)[0]
578578
elif isinstance(cons[0], (function_type, Expression)):

0 commit comments

Comments
 (0)