Closed timmens closed 9 months ago
@mdhaber this may be from some changes you've added in 1.3.0. Looks like tol is converted to a numpy array.
if tol is not None:
tol = np.asarray(tol)[()]
if tol.ndim != 0 or not np.issubdtype(tol.dtype, np.number) or tol <= 0:
raise ValueError('`tol` must be a positive scalar.')
I've made a simple fix for this and can make a bug fix release soon.
Hmm. If tol
is a Python float, tol = np.asarray(tol)[()]
makes it NumPy float, which is a Python float.
import numpy as np
x = 1.0
y = np.asarray(x)[()]
isinstance(y, type(x)) # True
So I didn't think that was backward incompatible. I added a test of tol
for SciPy's methods to make sure it was being passed to SciPy correctly (https://github.com/mechmotum/cyipopt/blob/0b6e7494a1cafc19f0dd3b683ace7bad89e28b3c/cyipopt/tests/unit/test_scipy_optional.py#L344), but I guess there were no tests of the tol
parameter before that checked it for IPOPT.
In any case, sorry for the trouble.
No trouble, its part of the process :)
Problem
Minimization using
cyipopt.minimize_ipopt
raises aTypeError
for thetol
argument on the same code in version 1.3.0 but not in version 1.2.0. Please take a look at the minimal reproducible example below.Minimal reproducible example
Error excerpt:
Probably caused by
It seems that
cyipopt.minimize_ipopt
calls the functioncyipopt.scipy_interface._minimize_ipopt_iv
internally (l.534), which converts the argumenttol
to anumpy.float
(l.668), which then causesnlp.add_option(option, value)
(l.598) to raise the TypeError.Full error message