Open
Description
solver.optimize
requires a scalar function. If provided with a function that has one dimension or more, than solver.optimize
(or actually sparse.take
) spits out an error message that is not very helpful to end users. Example:
from nutils import function, solver
solver.optimize('x', function.Argument('x', (1,))**2)
Traceback:
Traceback (most recent call last):
File "solver.py", line 834, in optimize
val, res, jac = _integrate_blocks(functional, residual, jacobian, arguments=lhs, mask=mask)
File "nutils/solver.py", line 981, in _integrate_blocks
res = [sparse.take(next(data), [m]) for m in mask]
File "nutils/solver.py", line 981, in <listcomp>
res = [sparse.take(next(data), [m]) for m in mask]
File "nutils/sparse.py", line 290, in take
assert axis == len(shape)
AssertionError
Let's raise an early (don't traverse into _integrate_blocks
) and informative exception instead.