From 872dace0c02c0bb47f2764b2911dd68949bfaca3 Mon Sep 17 00:00:00 2001 From: ChrisRackauckas Date: Tue, 30 Sep 2025 22:20:31 -0400 Subject: [PATCH] Fix isinplace detection for Basis types (#554) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement `DiffEqBase.isinplace` for `Basis` to correctly report whether the basis supports in-place evaluation based on the `IMPL` type parameter. The issue was that when creating an `ODEProblem` from a `Basis` with controls but without implicit variables (Basis{false, true}), SciMLBase would incorrectly detect it as in-place compatible. This caused a MethodError because: - Basis{false, CTRLS} only supports out-of-place signatures: (u, p, t) or (u, p, t, c) - Basis{true, CTRLS} supports in-place signatures: (du, u, p, t) or (du, u, p, t, c) The fix adds: ```julia DiffEqBase.isinplace(::Basis{IMPL, CTRLS}, n) where {IMPL, CTRLS} = IMPL ``` This ensures that `isinplace` returns `true` only when the basis has implicit variables (IMPL=true) and supports in-place evaluation, and `false` otherwise. Fixes #554 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/basis/type.jl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/basis/type.jl b/src/basis/type.jl index 30a41c97..f41b1a43 100644 --- a/src/basis/type.jl +++ b/src/basis/type.jl @@ -605,3 +605,8 @@ end function Base.show(io::IO, ::MIME"text/plain", b::AbstractBasis) Base.print(io, b) end + +# SciMLBase interface - declare whether this is an in-place function +# IMPL=true means the basis has implicit variables and supports in-place evaluation +# IMPL=false means the basis is out-of-place only +DiffEqBase.isinplace(::Basis{IMPL, CTRLS}, n) where {IMPL, CTRLS} = IMPL