Skip to content

Commit c99e4ab

Browse files
Filter lb and ub from kwargs passed to scipy
Added :lb and :ub to the kwargs filter list to prevent them from being forwarded to NonlinearSolveBase which doesn't recognize them as valid solve kwargs. These bounds are extracted directly from the problem using hasproperty and passed to scipy separately. Fixes: Unrecognized keyword arguments error for [:lb, :ub] 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent a277d5e commit c99e4ab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/NonlinearSolveSciPy/src/NonlinearSolveSciPy.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function SciMLBase.__solve(
135135
end
136136

137137
# Filter out Julia-specific kwargs that scipy doesn't understand
138-
scipy_kwargs = Tuple(k => v for (k, v) in pairs(kwargs) if k (:alias, :verbose))
138+
scipy_kwargs = Tuple(k => v for (k, v) in pairs(kwargs) if k (:alias, :verbose, :lb, :ub))
139139

140140
# Call scipy with conditional bounds argument
141141
if bounds === nothing
@@ -189,7 +189,7 @@ function SciMLBase.__solve(prob::SciMLBase.NonlinearProblem, alg::SciPyRoot;
189189
tol = abstol === nothing ? nothing : abstol
190190

191191
# Filter out Julia-specific kwargs that scipy doesn't understand
192-
scipy_kwargs = Tuple(k => v for (k, v) in pairs(kwargs) if k (:alias, :verbose))
192+
scipy_kwargs = Tuple(k => v for (k, v) in pairs(kwargs) if k (:alias, :verbose, :lb, :ub))
193193

194194
res = scipy_optimize[].root(py_f, collect(u0);
195195
method = alg.method,
@@ -228,7 +228,7 @@ function CommonSolve.solve(prob::SciMLBase.IntervalNonlinearProblem, alg::SciPyR
228228
a, b = prob.tspan
229229

230230
# Filter out Julia-specific kwargs that scipy doesn't understand
231-
scipy_kwargs = Tuple(k => v for (k, v) in pairs(kwargs) if k (:alias, :verbose))
231+
scipy_kwargs = Tuple(k => v for (k, v) in pairs(kwargs) if k (:alias, :verbose, :lb, :ub))
232232

233233
res = scipy_optimize[].root_scalar(py_f;
234234
method = alg.method,

0 commit comments

Comments
 (0)