Skip to content

Commit d0ea691

Browse files
Merge pull request #2760 from SciML/ChrisRackauckas-patch-6
Update to SymbolicUtils v2
2 parents d6240ce + 1f41c61 commit d0ea691

25 files changed

+133
-130
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ SparseArrays = "1"
107107
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
108108
StaticArrays = "0.10, 0.11, 0.12, 1.0"
109109
SymbolicIndexingInterface = "0.3.12"
110-
SymbolicUtils = "<1.6"
111-
Symbolics = "5.26"
110+
SymbolicUtils = "2"
111+
Symbolics = "5.30.1"
112112
URIs = "1"
113113
UnPack = "0.1, 1.0"
114114
Unitful = "1.1"

src/ModelingToolkit.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ using PrecompileTools, Reexport
99
end
1010

1111
import SymbolicUtils
12-
import SymbolicUtils: istree, arguments, operation, similarterm, promote_symtype,
12+
import SymbolicUtils: iscall, arguments, operation, maketerm, promote_symtype,
1313
Symbolic, isadd, ismul, ispow, issym, FnType,
1414
@rule, Rewriters, substitute, metadata, BasicSymbolic,
1515
Sym, Term
@@ -59,7 +59,7 @@ using Symbolics: _parse_vars, value, @derivatives, get_variables,
5959
exprs_occur_in, solve_for, build_expr, unwrap, wrap,
6060
VariableSource, getname, variable, Connection, connect,
6161
NAMESPACE_SEPARATOR, set_scalar_metadata, setdefaultval,
62-
initial_state, transition, activeState, entry,
62+
initial_state, transition, activeState, entry, hasnode,
6363
ticksInState, timeInState, fixpoint_sub, fast_substitute
6464
import Symbolics: rename, get_variables!, _solve, hessian_sparsity,
6565
jacobian_sparsity, isaffine, islinear, _iszero, _isone,

src/clock.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function is_continuous_domain(x)
2121
end
2222

2323
function get_time_domain(x)
24-
if istree(x) && operation(x) isa Operator
24+
if iscall(x) && operation(x) isa Operator
2525
output_timedomain(x)
2626
else
2727
getmetadata(x, TimeDomain, nothing)
@@ -130,7 +130,7 @@ is_concrete_time_domain(x) = x isa Union{AbstractClock, Continuous}
130130
SolverStepClock()
131131
SolverStepClock(t)
132132
133-
A clock that ticks at each solver step (sometimes referred to as "continuous sample time"). This clock **does generally not have equidistant tick intervals**, instead, the tick interval depends on the adaptive step-size slection of the continuous solver, as well as any continuous event handling. If adaptivity of the solver is turned off and there are no continuous events, the tick interval will be given by the fixed solver time step `dt`.
133+
A clock that ticks at each solver step (sometimes referred to as "continuous sample time"). This clock **does generally not have equidistant tick intervals**, instead, the tick interval depends on the adaptive step-size slection of the continuous solver, as well as any continuous event handling. If adaptivity of the solver is turned off and there are no continuous events, the tick interval will be given by the fixed solver time step `dt`.
134134
135135
Due to possibly non-equidistant tick intervals, this clock should typically not be used with discrete-time systems that assume a fixed sample time, such as PID controllers and digital filters.
136136
"""

src/debugging.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ end
2828

2929
debug_sub(eq::Equation) = debug_sub(eq.lhs) ~ debug_sub(eq.rhs)
3030
function debug_sub(ex)
31-
istree(ex) || return ex
31+
iscall(ex) || return ex
3232
f = operation(ex)
3333
args = map(debug_sub, arguments(ex))
3434
f in LOGGED_FUN ? logged_fun(f, args...) :
35-
similarterm(ex, f, args, metadata = metadata(ex))
35+
maketerm(typeof(ex), f, args, symtype(t), metadata(ex))
3636
end

src/discretedomain.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ end
3939
function (D::Shift)(x::Num, allow_zero = false)
4040
!allow_zero && D.steps == 0 && return x
4141
vt = value(x)
42-
if istree(vt)
42+
if iscall(vt)
4343
op = operation(vt)
4444
if op isa Sample
4545
error("Cannot shift a `Sample`. Create a variable to represent the sampled value and shift that instead")

src/inputoutput.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function outputs(sys)
1919
lhss = [eq.lhs for eq in o]
2020
unique([filter(isoutput, unknowns(sys))
2121
filter(isoutput, parameters(sys))
22-
filter(x -> istree(x) && isoutput(x), rhss) # observed can return equations with complicated expressions, we are only looking for single Terms
23-
filter(x -> istree(x) && isoutput(x), lhss)])
22+
filter(x -> iscall(x) && isoutput(x), rhss) # observed can return equations with complicated expressions, we are only looking for single Terms
23+
filter(x -> iscall(x) && isoutput(x), lhss)])
2424
end
2525

2626
"""

src/parameters.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ function isparameter(x)
1515
isparameter(p) ||
1616
(hasmetadata(p, Symbolics.VariableSource) &&
1717
getmetadata(p, Symbolics.VariableSource)[1] == :parameters)
18-
elseif istree(x) && operation(x) isa Symbolic
18+
elseif iscall(x) && operation(x) isa Symbolic
1919
varT === PARAMETER || isparameter(operation(x))
20-
elseif istree(x) && operation(x) == (getindex)
20+
elseif iscall(x) && operation(x) == (getindex)
2121
isparameter(arguments(x)[1])
2222
elseif x isa Symbolic
2323
varT === PARAMETER

src/structural_transformation/StructuralTransformations.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ using Symbolics: unwrap, linear_expansion, fast_substitute
77
using SymbolicUtils
88
using SymbolicUtils.Code
99
using SymbolicUtils.Rewriters
10-
using SymbolicUtils: similarterm, istree
10+
using SymbolicUtils: maketerm, iscall
1111

1212
using ModelingToolkit
1313
using ModelingToolkit: ODESystem, AbstractSystem, var_from_nested_derivative, Differential,

src/structural_transformation/symbolics_tearing.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function full_equations(sys::AbstractSystem; simplify = false)
9292
@unpack subs = substitutions
9393
solved = Dict(eq.lhs => eq.rhs for eq in subs)
9494
neweqs = map(equations(sys)) do eq
95-
if istree(eq.lhs) && operation(eq.lhs) isa Union{Shift, Differential}
95+
if iscall(eq.lhs) && operation(eq.lhs) isa Union{Shift, Differential}
9696
return tearing_sub(eq.lhs, solved, simplify) ~ tearing_sub(eq.rhs, solved,
9797
simplify)
9898
else
@@ -568,7 +568,7 @@ function tearing_reassemble(state::TearingState, var_eq_matching,
568568

569569
for eq in obs
570570
lhs = eq.lhs
571-
istree(lhs) || continue
571+
iscall(lhs) || continue
572572
operation(lhs) === getindex || continue
573573
Symbolics.shape(lhs) !== Symbolics.Unknown() || continue
574574
arg1 = arguments(lhs)[1]

src/structural_transformation/utils.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ function simplify_shifts(var)
445445
t2 = op2.t
446446
return simplify_shifts(ModelingToolkit.Shift(t1 === nothing ? t2 : t1, s1 + s2)(vv2))
447447
else
448-
return similarterm(var, operation(var), simplify_shifts.(arguments(var)),
449-
Symbolics.symtype(var); metadata = unwrap(var).metadata)
448+
return maketerm(typeof(var), operation(var), simplify_shifts.(arguments(var)),
449+
Symbolics.symtype(var), unwrap(var).metadata)
450450
end
451451
end

0 commit comments

Comments
 (0)