Skip to content

Commit f61d112

Browse files
authored
Merge pull request #876 from SciML/myb/sub
Remove `Num` substitute overloads.
2 parents ff574e6 + 1903f16 commit f61d112

File tree

3 files changed

+3
-40
lines changed

3 files changed

+3
-40
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Setfield = "0.7"
6565
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0"
6666
StaticArrays = "0.10, 0.11, 0.12, 1.0"
6767
SymbolicUtils = "0.8.3, 0.9"
68-
Symbolics = "0.1.2"
68+
Symbolics = "0.1.7"
6969
TreeViews = "0.3"
7070
UnPack = "0.1, 1.0"
7171
Unitful = "1.1"

src/ModelingToolkit.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import Symbolics: rename, get_variables!, _solve, hessian_sparsity,
4343
BuildTargets, JuliaTarget, StanTarget, CTarget, MATLABTarget,
4444
ParallelForm, SerialForm, MultithreadedForm, build_function,
4545
unflatten_long_ops, rhss, lhss, prettify_expr, gradient,
46-
jacobian, hessian, derivative, sparsejacobian, sparsehessian
46+
jacobian, hessian, derivative, sparsejacobian, sparsehessian,
47+
substituter
4748

4849
import DiffEqBase: @add_kwonly
4950

src/utils.jl

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -35,44 +35,6 @@ end
3535

3636
modified_states!(mstates, e::Equation, statelist=nothing) = get_variables!(mstates, e.lhs, statelist)
3737

38-
# variable substitution
39-
# Piracy but mild
40-
"""
41-
substitute(expr, s::Pair)
42-
substitute(expr, s::Dict)
43-
substitute(expr, s::Vector)
44-
45-
Performs the substitution on `expr` according to rule(s) `s`.
46-
47-
# Examples
48-
```julia
49-
julia> @parameters t
50-
(t,)
51-
52-
julia> @variables x y z(t)
53-
(x, y, z(t))
54-
55-
julia> ex = x + y + sin(z)
56-
(x + y) + sin(z(t))
57-
58-
julia> substitute(ex, Dict([x => z, sin(z) => z^2]))
59-
(z(t) + y) + (z(t) ^ 2)
60-
```
61-
"""
62-
# cannot use Union{Pair, Vector, Dict} -- leads to ambiguity
63-
substitute(expr::Num, s::Pair; kw...) = Num(substituter(s)(value(expr); kw...))
64-
substitute(expr::Num, s::Vector; kw...) = Num(substituter(s)(value(expr); kw...))
65-
substitute(expr::Num, s::Dict; kw...) = Num(substituter(s)(value(expr); kw...))
66-
# TODO: move this to SymbolicUtils
67-
substitute(expr, s::Pair; kw...) = substituter([s[1] => s[2]])(expr; kw...)
68-
substitute(expr, s::Vector; kw...) = substituter(s)(expr; kw...)
69-
70-
substituter(pair::Pair) = substituter((pair,))
71-
function substituter(pairs)
72-
dict = Dict(value(k) => value(v) for (k, v) in pairs)
73-
(expr; kw...) -> SymbolicUtils.substitute(expr, dict; kw...)
74-
end
75-
7638
macro showarr(x)
7739
n = string(x)
7840
quote

0 commit comments

Comments
 (0)