|
21 | 21 |
|
22 | 22 | using CommonSolve |
23 | 23 | using SciMLBase |
| 24 | +using SciMLBase: allowsbounds |
24 | 25 | using NonlinearSolveBase: AbstractNonlinearSolveAlgorithm, |
25 | 26 | construct_extension_function_wrapper |
26 | 27 |
|
@@ -123,12 +124,10 @@ function SciMLBase.__solve( |
123 | 124 | # Construct Python residual |
124 | 125 | py_f = _make_py_residual(prob.f, prob.p) |
125 | 126 |
|
126 | | - # Bounds handling (lb/ub may be missing) |
127 | | - has_lb = hasproperty(prob, :lb) |
128 | | - has_ub = hasproperty(prob, :ub) |
129 | | - if has_lb || has_ub |
130 | | - lb = has_lb ? getproperty(prob, :lb) : fill(-Inf, length(prob.u0)) |
131 | | - ub = has_ub ? getproperty(prob, :ub) : fill(Inf, length(prob.u0)) |
| 127 | + # Bounds handling from problem fields |
| 128 | + if prob.lb !== nothing || prob.ub !== nothing |
| 129 | + lb = prob.lb !== nothing ? prob.lb : fill(-Inf, length(prob.u0)) |
| 130 | + ub = prob.ub !== nothing ? prob.ub : fill(Inf, length(prob.u0)) |
132 | 131 | bounds = (lb, ub) |
133 | 132 | else |
134 | 133 | bounds = nothing |
@@ -257,6 +256,11 @@ function CommonSolve.solve(prob::SciMLBase.IntervalNonlinearProblem, alg::SciPyR |
257 | 256 | original = res, stats = stats) |
258 | 257 | end |
259 | 258 |
|
| 259 | +# Trait declarations |
| 260 | +SciMLBase.allowsbounds(::SciPyLeastSquares) = true |
| 261 | +SciMLBase.allowsbounds(::SciPyRoot) = false |
| 262 | +SciMLBase.allowsbounds(::SciPyRootScalar) = false |
| 263 | + |
260 | 264 | @reexport using SciMLBase, NonlinearSolveBase |
261 | 265 |
|
262 | 266 | export SciPyLeastSquares, SciPyLeastSquaresTRF, SciPyLeastSquaresDogbox, |
|
0 commit comments