Skip to content

Commit 898f9ac

Browse files
Merge pull request #1129 from ChrisRackauckas-Claude/fix-optimization-function-iip-check
Fix OptimizationFunction{false} isinplace check
2 parents 1eb35ad + a02b23f commit 898f9ac

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/scimlfunctions.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4279,7 +4279,6 @@ function OptimizationFunction{iip}(f, adtype::AbstractADType = NoAD();
42794279
lag_hess_colorvec = nothing,
42804280
initialization_data = __has_initialization_data(f) ? f.initialization_data :
42814281
nothing) where {iip}
4282-
isinplace(f, 2; has_two_dispatches = false, isoptimization = true)
42834282
sys = sys_or_symbolcache(sys, syms, paramsyms)
42844283
OptimizationFunction{
42854284
iip, typeof(adtype), typeof(f), typeof(grad), typeof(fg), typeof(hess),

test/function_building_error_messages.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,14 @@ optf(u, p) = 1.0
507507
OptimizationFunction(optf)
508508
OptimizationProblem(optf, 1.0)
509509

510+
# Test OptimizationFunction{iip} respects explicit iip parameter
511+
# This function would fail isinplace check due to method ambiguity
512+
struct ProblematicOptFunction end
513+
(::ProblematicOptFunction)(x, p) = sum(x .^ 2)
514+
# But when iip is explicitly provided, it should work without calling isinplace
515+
@test_nowarn OptimizationFunction{false}(ProblematicOptFunction())
516+
@test_nowarn OptimizationFunction{true}(ProblematicOptFunction())
517+
510518
# BVPFunction
511519

512520
bfoop(u, p, t) = u

0 commit comments

Comments
 (0)