Skip to content

The two-function types cannot be rebuilt with @set, and DynamicalDDEFunction cannot be constructed #1625

Description

@singhharsh1708

constructorof is overloaded for ODEFunction and the other one-function types but not for SplitFunction, DynamicalODEFunction, DynamicalDDEFunction, SplitSDEFunction or DynamicalSDEFunction, so @set and @reset fall back to a positional constructor those types don't have:

using SciMLBase, Accessors
f1(dv, v, u, p, t) = (dv .= -u; nothing)
f2(du, v, u, p, t) = (du .= v; nothing)
fn = DynamicalODEFunction(f1, f2; jac_prototype = zeros(2, 2))
@set fn.jac_prototype = zeros(Float32, 2, 2)
ERROR: MethodError: no method matching DynamicalODEFunction(::ODEFunction{true, SciMLBase.AutoSpecialize, typeof(f1), ...}, ::ODEFunction{true, ...}, ::UniformScaling{Bool}, ::Nothing, ...)

The practical fallout is in DiffEqBase: promote_f does exactly this @set on any jac_prototype <: AbstractArray, so solve and init throw on every SecondOrderODEProblem or DynamicalODEProblem whose function carries a jac_prototype, dense or sparse, before any solver sees it (DiffEqBase 7.21.2, SciMLBase 3.56.1).

Writing a test for this also turned up that DynamicalDDEFunction(f1, f2) can't be constructed at all: the keyword constructor's initialization_data default reads f instead of f1, and its return type leaves out the specialize parameter, so it throws an UndefVarError, and a MethodError once that's fixed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions