From 7331449c039a253b7adb8732c3430b93075189b6 Mon Sep 17 00:00:00 2001 From: Sbhat92 Date: Tue, 9 May 2023 15:29:38 -0400 Subject: [PATCH 1/2] exception to non-scalar passsed to solver.optimizer --- nutils/solver.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nutils/solver.py b/nutils/solver.py index e3cba58b9..2c39ad74e 100644 --- a/nutils/solver.py +++ b/nutils/solver.py @@ -763,6 +763,8 @@ def _optimize(target, functional: evaluable.asarray, constrain, arguments, tol: dtype = _determine_dtype(target, (functional,), lhs0, constrain) mask, vmask = _invert(constrain, target) lhs, vlhs = _redict(lhs0, target, dtype) + if functional.shape != (): + raise ValueError('The objective function must be a scalar function of a single variable') val, res, jac = _integrate_blocks(functional, residual, jacobian, arguments=lhs, mask=mask) if droptol is not None: supp = jac.rowsupp(droptol) From 6fcf81de61efe50a73365a3e692afbec96e0ba15 Mon Sep 17 00:00:00 2001 From: Sbhat92 Date: Wed, 10 May 2023 20:29:49 -0400 Subject: [PATCH 2/2] exception to non-scalar passsed to solver.optimizer --- nutils/solver.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nutils/solver.py b/nutils/solver.py index 2c39ad74e..5f66cebbb 100644 --- a/nutils/solver.py +++ b/nutils/solver.py @@ -763,8 +763,8 @@ def _optimize(target, functional: evaluable.asarray, constrain, arguments, tol: dtype = _determine_dtype(target, (functional,), lhs0, constrain) mask, vmask = _invert(constrain, target) lhs, vlhs = _redict(lhs0, target, dtype) - if functional.shape != (): - raise ValueError('The objective function must be a scalar function of a single variable') + if functional.ndim != 0: + raise ValueError('the objective function must be scalar valued') val, res, jac = _integrate_blocks(functional, residual, jacobian, arguments=lhs, mask=mask) if droptol is not None: supp = jac.rowsupp(droptol)