Skip to content

Commit 018e2d6

Browse files
refactor: add depwarns for old system and problem constructors
1 parent 3703a1e commit 018e2d6

File tree

1 file changed

+162
-0
lines changed

1 file changed

+162
-0
lines changed

src/deprecations.jl

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,165 @@ macro mtkbuild(exprs...)
88
@mtkcompile $(exprs...)
99
end |> esc
1010
end
11+
12+
for T in [:ODESystem, :NonlinearSystem, :DiscreteSystem, :ImplicitDiscreteSystem]
13+
@eval @deprecate $T(args...; kwargs...) System(args...; kwargs...)
14+
end
15+
16+
for T in [:ODEProblem, :DDEProblem, :SDEProblem, :SDDEProblem, :DAEProblem,
17+
:BVProblem, :DiscreteProblem, :ImplicitDiscreteProblem]
18+
for (pType, pCanonical) in [
19+
(AbstractDict, :p),
20+
(AbstractArray{<:Pair}, :(Dict(p))),
21+
(AbstractArray, :(isempty(p) ? Dict() : Dict(parameters(sys) .=> p)))
22+
],
23+
(uType, uCanonical) in [
24+
(Nothing, :(Dict())),
25+
(AbstractDict, :u0),
26+
(AbstractArray{<:Pair}, :(Dict(u0))),
27+
(AbstractArray, :(isempty(u0) ? Dict() : Dict(unknowns(sys) .=> u0)))
28+
]
29+
30+
@eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...)
31+
ctor = string($T)
32+
uCan = string($(QuoteNode(uCanonical)))
33+
pCan = string($(QuoteNode(pCanonical)))
34+
@warn """
35+
`$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use
36+
`$ctor(sys, merge($uCan, $pCan), tspan)` instead.
37+
"""
38+
SciMLBase.$T(sys, merge($uCanonical, $pCanonical), tspan; kw...)
39+
end
40+
@eval function SciMLBase.$T{iip}(
41+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip}
42+
ctor = string($T{iip})
43+
uCan = string($(QuoteNode(uCanonical)))
44+
pCan = string($(QuoteNode(pCanonical)))
45+
@warn """
46+
`$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use
47+
`$ctor(sys, merge($uCan, $pCan), tspan)` instead.
48+
"""
49+
return SciMLBase.$T{iip}(sys, merge($uCanonical, $pCanonical), tspan; kw...)
50+
end
51+
@eval function SciMLBase.$T{iip, spec}(
52+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip, spec}
53+
ctor = string($T{iip, spec})
54+
uCan = string($(QuoteNode(uCanonical)))
55+
pCan = string($(QuoteNode(pCanonical)))
56+
@warn """
57+
`$ctor(sys, u0, tspan, p; kw...)` is deprecated. Use
58+
`$ctor(sys, merge($uCan, $pCan), tspan)` instead.
59+
"""
60+
return $T{iip, spec}(sys, merge($uCanonical, $pCanonical), tspan; kw...)
61+
end
62+
end
63+
64+
for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing]
65+
@eval function SciMLBase.$T(sys::System, u0::$uType, tspan, p::$pType; kw...)
66+
ctor = string($T)
67+
pT = string($(QuoteNode(pType)))
68+
@warn """
69+
`$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use
70+
`$ctor(sys, u0, tspan)` instead.
71+
"""
72+
$T(sys, u0, tspan; kw...)
73+
end
74+
@eval function SciMLBase.$T{iip}(
75+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip}
76+
ctor = string($T{iip})
77+
pT = string($(QuoteNode(pType)))
78+
@warn """
79+
`$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use
80+
`$ctor(sys, u0, tspan)` instead.
81+
"""
82+
return $T{iip}(sys, u0, tspan; kw...)
83+
end
84+
@eval function SciMLBase.$T{iip, spec}(
85+
sys::System, u0::$uType, tspan, p::$pType; kw...) where {iip, spec}
86+
ctor = string($T{iip, spec})
87+
pT = string($(QuoteNode(pType)))
88+
@warn """
89+
`$ctor(sys, u0, tspan, p::$pT; kw...)` is deprecated. Use
90+
`$ctor(sys, u0, tspan)` instead.
91+
"""
92+
return $T{iip, spec}(sys, u0, tspan; kw...)
93+
end
94+
end
95+
end
96+
97+
for T in [:NonlinearProblem, :NonlinearLeastSquaresProblem,
98+
:SCCNonlinearProblem, :OptimizationProblem, :SteadyStateProblem]
99+
for (pType, pCanonical) in [
100+
(AbstractDict, :p),
101+
(AbstractArray{<:Pair}, :(Dict(p))),
102+
(AbstractArray, :(isempty(p) ? Dict() : Dict(parameters(sys) .=> p)))
103+
],
104+
(uType, uCanonical) in [
105+
(Nothing, :(Dict())),
106+
(AbstractDict, :u0),
107+
(AbstractArray{<:Pair}, :(Dict(u0))),
108+
(AbstractArray, :(isempty(u0) ? Dict() : Dict(unknowns(sys) .=> u0)))
109+
]
110+
111+
@eval function SciMLBase.$T(sys::System, u0::$uType, p::$pType; kw...)
112+
ctor = string($T)
113+
uCan = string($(QuoteNode(uCanonical)))
114+
pCan = string($(QuoteNode(pCanonical)))
115+
@warn """
116+
`$ctor(sys, u0, p; kw...)` is deprecated. Use `$ctor(sys, merge($uCan, $pCan))`
117+
instead.
118+
"""
119+
$T(sys, merge($uCanonical, $pCanonical); kw...)
120+
end
121+
@eval function SciMLBase.$T{iip}(
122+
sys::System, u0::$uType, p::$pType; kw...) where {iip}
123+
ctor = string($T{iip})
124+
uCan = string($(QuoteNode(uCanonical)))
125+
pCan = string($(QuoteNode(pCanonical)))
126+
@warn """
127+
`$ctor(sys, u0, p; kw...)` is deprecated. Use `$ctor(sys, merge($uCan, $pCan))`
128+
instead.
129+
"""
130+
return $T{iip}(sys, merge($uCanonical, $pCanonical); kw...)
131+
end
132+
@eval function SciMLBase.$T{iip, spec}(
133+
sys::System, u0::$uType, p::$pType; kw...) where {iip, spec}
134+
ctor = string($T{iip, spec})
135+
uCan = string($(QuoteNode(uCanonical)))
136+
pCan = string($(QuoteNode(pCanonical)))
137+
@warn """
138+
`$ctor(sys, u0, p; kw...)` is deprecated. Use `$ctor(sys, merge($uCan, $pCan))`
139+
instead.
140+
"""
141+
return $T{iip, spec}(sys, merge($uCanonical, $pCanonical); kw...)
142+
end
143+
end
144+
for pType in [SciMLBase.NullParameters, Nothing], uType in [Any, Nothing]
145+
@eval function SciMLBase.$T(sys::System, u0::$uType, p::$pType; kw...)
146+
ctor = string($T)
147+
pT = string($(QuoteNode(pType)))
148+
@warn """
149+
`$ctor(sys, u0, p::$pT; kw...)` is deprecated. Use `$ctor(sys, u0)` instead
150+
"""
151+
$T(sys, u0; kw...)
152+
end
153+
@eval function SciMLBase.$T{iip}(
154+
sys::System, u0::$uType, p::$pType; kw...) where {iip}
155+
ctor = string($T{iip})
156+
pT = string($(QuoteNode(pType)))
157+
@warn """
158+
`$ctor(sys, u0, p::$pT; kw...)` is deprecated. Use `$ctor(sys, u0)` instead
159+
"""
160+
return $T{iip}(sys, u0; kw...)
161+
end
162+
@eval function SciMLBase.$T{iip, spec}(
163+
sys::System, u0::$uType, p::$pType; kw...) where {iip, spec}
164+
ctor = string($T{iip, spec})
165+
pT = string($(QuoteNode(pType)))
166+
@warn """
167+
`$ctor(sys, u0, p::$pT; kw...)` is deprecated. Use `$ctor(sys, u0)` instead
168+
"""
169+
return $T{iip, spec}(sys, u0; kw...)
170+
end
171+
end
172+
end

0 commit comments

Comments
 (0)