You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bounds given as a list or tuple raise AttributeError when params is a numpy array #725
When params is a 1d numpy array and no constraints or scaling are used, get_converter takes a fast path (_get_fast_path_converter in src/optimagic/parameters/conversion.py). That fast path calls bounds.lower.astype(float) and bounds.upper.astype(float) directly instead of going through get_internal_bounds. As a result, om.Bounds with a list or tuple as lower or upper fails with AttributeError. The deprecated lower_bounds=[...] argument fails the same way, because it is converted into Bounds(lower=list).
The same bounds work as soon as the problem leaves the fast path, for example with scaling=True, because the slow path processes bounds through get_internal_bounds. The fast path also skips the lower > upper check and the conversion of all-infinite bounds to None that get_internal_bounds performs.
To Reproduce
importnumpyasnpimportoptimagicasomparams=np.array([1.0, 2.0, 3.0])
om.minimize(lambdax: x @ x, params, algorithm="scipy_lbfgsb",
bounds=om.Bounds(lower=[0.5, 0.5, 0.5]))
# AttributeError: 'list' object has no attribute 'astype'om.minimize(lambdax: x @ x, params, algorithm="scipy_lbfgsb",
bounds=om.Bounds(lower=[0.5, 0.5, 0.5]), scaling=True)
# works, params = [0.5, 0.5, 0.5]
Expected behavior
Bounds that work on the slow path should also work on the fast path. Calling get_internal_bounds(params=params, bounds=bounds) in _get_fast_path_converter would do this. It already has its own fast path for 1d array bounds, so the behavior for array bounds stays the same. I have a small patch with a regression test in tests/optimagic/parameters/test_conversion.py and can open a PR if that is welcome.
System
OS: macOS 15
Version: optimagic main at 2b1eea8 (0.5.5.dev17), Python 3.12
Disclosure: found, reproduced and the draft fix tested locally with the help of an AI coding agent (Claude Code); reviewed before filing.
Hi @JoeyTan21, thanks for the very clear and thorough report! We'd be happy to receive a PR with your fix if you want to contribute.
I found another bug in get_internal_bounds while looking into this and opened #729 to fix it, so you don't need to take care of that. Feel free to open your PR in the meantime!
Activity
timmens commentedon Oct 30, 2026
Hi @JoeyTan21, thanks for the very clear and thorough report! We'd be happy to receive a PR with your fix if you want to contribute.
I found another bug in
get_internal_boundswhile looking into this and opened #729 to fix it, so you don't need to take care of that. Feel free to open your PR in the meantime!