Skip to content

Commit a45fef8

Browse files
refactor: deprecate structural_simplify and @mtkbuild
1 parent 52d3ab8 commit a45fef8

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

src/ModelingToolkit.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ include("structural_transformation/StructuralTransformations.jl")
214214
include("inputoutput.jl")
215215

216216
include("adjoints.jl")
217+
include("deprecations.jl")
217218

218219
const t_nounits = let
219220
only(@independent_variables t)
@@ -288,7 +289,7 @@ export alias_elimination, flatten
288289
export connect, domain_connect, @connector, Connection, AnalysisPoint, Flow, Stream,
289290
instream
290291
export initial_state, transition, activeState, entry, ticksInState, timeInState
291-
export @component, @mtkmodel, @mtkcompile
292+
export @component, @mtkmodel, @mtkcompile, @mtkbuild
292293
export isinput, isoutput, getbounds, hasbounds, getguess, hasguess, isdisturbance,
293294
istunable, getdist, hasdist,
294295
tunable_parameters, isirreducible, getdescription, hasdescription,
@@ -305,7 +306,7 @@ export independent_variable, equations, controls, observed, full_equations, jump
305306
brownians
306307
export initialization_equations, guesses, defaults, parameter_dependencies, hierarchy
307308
export mtkcompile, expand_connections, linearize, linearization_function,
308-
LinearizationProblem
309+
LinearizationProblem, structural_simplify
309310
export solve
310311
export Pre
311312

src/deprecations.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@deprecate structural_simplify(sys; kwargs...) mtkcompile(sys; kwargs...)
2+
@deprecate structural_simplify(sys, io; kwargs...) mtkcompile(
3+
sys; inputs = io[1], outputs = io[2], kwargs...)
4+
5+
macro mtkbuild(exprs...)
6+
return quote
7+
Base.depwarn("`@mtkbuild` is deprecated. Use `@mtkcompile` instead.", :mtkbuild)
8+
@mtkcompile $(exprs...)
9+
end |> esc
10+
end
11+

test/structural_transformation/utils.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,3 +436,10 @@ end
436436
@test integ.ps[p] 3.0
437437
end
438438
end
439+
440+
@testset "Deprecated `structural_simplify` and `@mtkbuild`" begin
441+
@variables x(t)
442+
@test_deprecated @mtkbuild sys = System([D(x) ~ x], t)
443+
@named sys = System([D(x) ~ x], t)
444+
@test_deprecated structural_simplify(sys)
445+
end

0 commit comments

Comments
 (0)