Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/ModelingToolkit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ $(TYPEDEF)
TODO
"""
abstract type AbstractSystem end
# Solely so that `ODESystem` can be deprecated and still act as a valid type.
# See `deprecations.jl`.
abstract type IntermediateDeprecationSystem <: AbstractSystem end

function independent_variable end

Expand Down Expand Up @@ -275,7 +278,7 @@ PrecompileTools.@compile_workload begin
end

export ODEFunction, convert_system_indepvar,
System, OptimizationSystem, JumpSystem, SDESystem, NonlinearSystem
System, OptimizationSystem, JumpSystem, SDESystem, NonlinearSystem, ODESystem
export SDEFunction
export SystemStructure
export DiscreteProblem, DiscreteFunction
Expand Down
10 changes: 9 additions & 1 deletion src/deprecations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@ macro mtkbuild(exprs...)
end |> esc
end

for T in [:ODESystem, :NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem]
const ODESystem = IntermediateDeprecationSystem

function IntermediateDeprecationSystem(args...; kwargs...)
Base.depwarn("`ODESystem(args...; kwargs...)` is deprecated. Use `System(args...; kwargs...) instead`.", :ODESystem)

return System(args...; kwargs...)
end

for T in [:NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem]
@eval @deprecate $T(args...; kwargs...) System(args...; kwargs...)
end

Expand Down
2 changes: 1 addition & 1 deletion src/systems/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ structure.

$(TYPEDFIELDS)
"""
struct System <: AbstractSystem
struct System <: IntermediateDeprecationSystem
"""
$INTERNAL_FIELD_WARNING
A unique integer tag for the system.
Expand Down
14 changes: 14 additions & 0 deletions test/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1600,3 +1600,17 @@ end
@test getmetadata(sys, TestMeta, nothing) == "test"
@test getmetadata(sys2, TestMeta, nothing) == "test"
end

struct TestWrapper
sys::ODESystem
end

@testset "`ODESystem` is a type" begin
@variables x(t)
@named sys = ODESystem(D(x) ~ x, t)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a @test_warns here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a depwarn test somewhere else

@test sys isa ODESystem
@test sys isa System
arr = ODESystem[]
@test_nowarn push!(arr, sys)
@test_nowarn TestWrapper(sys)
end
Loading