Skip to content

Commit

Permalink
Merge pull request #2948 from SciML/ChrisRackauckas-patch-6
Browse files Browse the repository at this point in the history
Symbolics / SymbolicUtils / TermInterface bump
  • Loading branch information
ChrisRackauckas authored Aug 13, 2024
2 parents aecd4a3 + 25665fb commit e183abf
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 25 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Libdl = "1"
LinearAlgebra = "1"
MLStyle = "0.4.17"
NaNMath = "0.3, 1"
NonlinearSolve = "3.12"
NonlinearSolve = "3.14"
OrderedCollections = "1"
OrdinaryDiffEq = "6.82.0"
PrecompileTools = "1"
Expand All @@ -112,8 +112,8 @@ SparseArrays = "1"
SpecialFunctions = "0.7, 0.8, 0.9, 0.10, 1.0, 2"
StaticArrays = "0.10, 0.11, 0.12, 1.0"
SymbolicIndexingInterface = "0.3.28"
SymbolicUtils = "2.1"
Symbolics = "5.32"
SymbolicUtils = "3.1.2"
Symbolics = "6"
URIs = "1"
UnPack = "0.1, 1.0"
Unitful = "1.1"
Expand Down
4 changes: 2 additions & 2 deletions docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ Plots = "1.36"
SciMLStructures = "1.1"
StochasticDiffEq = "6"
SymbolicIndexingInterface = "0.3.1"
SymbolicUtils = "2, 3"
Symbolics = "5"
SymbolicUtils = "3"
Symbolics = "6"
Unitful = "1.12"
2 changes: 1 addition & 1 deletion src/debugging.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ function debug_sub(ex)
f = operation(ex)
args = map(debug_sub, arguments(ex))
f in LOGGED_FUN ? logged_fun(f, args...) :
maketerm(typeof(ex), f, args, symtype(t), metadata(ex))
maketerm(typeof(ex), f, args, metadata(ex))
end
2 changes: 1 addition & 1 deletion src/structural_transformation/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,6 @@ function simplify_shifts(var)
return simplify_shifts(ModelingToolkit.Shift(t1 === nothing ? t2 : t1, s1 + s2)(vv2))
else
return maketerm(typeof(var), operation(var), simplify_shifts.(arguments(var)),
Symbolics.symtype(var), unwrap(var).metadata)
unwrap(var).metadata)
end
end
19 changes: 9 additions & 10 deletions src/systems/abstractsystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1090,7 +1090,7 @@ function _apply_to_variables(f::F, ex) where {F}
iscall(ex) || return ex
maketerm(typeof(ex), _apply_to_variables(f, operation(ex)),
map(Base.Fix1(_apply_to_variables, f), arguments(ex)),
symtype(ex), metadata(ex))
metadata(ex))
end

abstract type SymScope end
Expand All @@ -1102,7 +1102,7 @@ function LocalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
args = arguments(sym)
a1 = setmetadata(args[1], SymScope, LocalScope())
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
symtype(sym), metadata(sym))
metadata(sym))
else
setmetadata(sym, SymScope, LocalScope())
end
Expand All @@ -1119,7 +1119,7 @@ function ParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
a1 = setmetadata(args[1], SymScope,
ParentScope(getmetadata(value(args[1]), SymScope, LocalScope())))
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
symtype(sym), metadata(sym))
metadata(sym))
else
setmetadata(sym, SymScope,
ParentScope(getmetadata(value(sym), SymScope, LocalScope())))
Expand All @@ -1138,7 +1138,7 @@ function DelayParentScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}}, N)
a1 = setmetadata(args[1], SymScope,
DelayParentScope(getmetadata(value(args[1]), SymScope, LocalScope()), N))
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
symtype(sym), metadata(sym))
metadata(sym))
else
setmetadata(sym, SymScope,
DelayParentScope(getmetadata(value(sym), SymScope, LocalScope()), N))
Expand All @@ -1154,7 +1154,7 @@ function GlobalScope(sym::Union{Num, Symbolic, Symbolics.Arr{Num}})
args = arguments(sym)
a1 = setmetadata(args[1], SymScope, GlobalScope())
maketerm(typeof(sym), operation(sym), [a1, args[2:end]...],
symtype(sym), metadata(sym))
metadata(sym))
else
setmetadata(sym, SymScope, GlobalScope())
end
Expand All @@ -1172,13 +1172,13 @@ function renamespace(sys, x)
if iscall(x) && operation(x) isa Operator
return maketerm(typeof(x), operation(x),
Any[renamespace(sys, only(arguments(x)))],
symtype(x), metadata(x))::T
metadata(x))::T
end
if iscall(x) && operation(x) === getindex
args = arguments(x)
return maketerm(
typeof(x), operation(x), vcat(renamespace(sys, args[1]), args[2:end]),
symtype(x), metadata(x))::T
metadata(x))::T
end
let scope = getmetadata(x, SymScope, LocalScope())
if scope isa LocalScope
Expand Down Expand Up @@ -1263,13 +1263,12 @@ function namespace_expr(
# metadata from the rescoped variable
rescoped = renamespace(n, O)
maketerm(typeof(rescoped), operation(rescoped), renamed,
symtype(rescoped),
metadata(rescoped))
elseif Symbolics.isarraysymbolic(O)
# promote_symtype doesn't work for array symbolics
maketerm(typeof(O), operation(O), renamed, symtype(O), metadata(O))
maketerm(typeof(O), operation(O), renamed, metadata(O))
else
maketerm(typeof(O), operation(O), renamed, symtype(O), metadata(O))
maketerm(typeof(O), operation(O), renamed, metadata(O))
end
elseif isvariable(O)
renamespace(n, O)
Expand Down
2 changes: 1 addition & 1 deletion src/systems/clock_inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ function substitute_sample_time(ex, dt)
end
new_args[i] = ex_arg
end
maketerm(typeof(ex), op, new_args, symtype(ex), metadata(ex))
maketerm(typeof(ex), op, new_args, metadata(ex))
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/systems/diffeqs/abstractodesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ function delay_to_function(expr, iv, sts, ps, h)
return maketerm(typeof(expr),
operation(expr),
map(x -> delay_to_function(x, iv, sts, ps, h), arguments(expr)),
symtype(expr), metadata(expr))
metadata(expr))
else
return expr
end
Expand Down
2 changes: 1 addition & 1 deletion src/systems/diffeqs/odesystem.jl
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ function convert_system(::Type{<:ODESystem}, sys, t; name = nameof(sys))
continue
end
ns = maketerm(typeof(s), operation(s), Any[t],
SymbolicUtils.symtype(s), SymbolicUtils.metadata(s))
SymbolicUtils.metadata(s))
newsts[i] = ns
varmap[s] = ns
else
Expand Down
2 changes: 1 addition & 1 deletion src/systems/systemstructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ using SparseArrays
function quick_cancel_expr(expr)
Rewriters.Postwalk(quick_cancel,
similarterm = (x, f, args; kws...) -> maketerm(typeof(x), f, args,
SymbolicUtils.symtype(x), SymbolicUtils.metadata(x),
SymbolicUtils.metadata(x),
kws...))(expr)
end

Expand Down
6 changes: 3 additions & 3 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ function detime_dvs(op)
Sym{Real}(nameof(operation(op)))
else
maketerm(typeof(op), operation(op), detime_dvs.(arguments(op)),
symtype(op), metadata(op))
metadata(op))
end
end

function retime_dvs(op, dvs, iv)
issym(op) && return Sym{FnType{Tuple{symtype(iv)}, Real}}(nameof(op))(iv)
iscall(op) ?
maketerm(typeof(op), operation(op), retime_dvs.(arguments(op), (dvs,), (iv,)),
symtype(op), metadata(op)) :
metadata(op)) :
op
end

Expand Down Expand Up @@ -833,7 +833,7 @@ end
function fold_constants(ex)
if iscall(ex)
maketerm(typeof(ex), operation(ex), map(fold_constants, arguments(ex)),
symtype(ex), metadata(ex))
metadata(ex))
elseif issym(ex) && isconstant(ex)
getdefault(ex)
else
Expand Down
2 changes: 1 addition & 1 deletion src/variables.jl
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ ishistory(x::Symbolic) = getmetadata(x, IsHistory, false)
hist(x, t) = wrap(hist(unwrap(x), t))
function hist(x::Symbolic, t)
setmetadata(
toparam(maketerm(typeof(x), operation(x), [unwrap(t)], symtype(x), metadata(x))),
toparam(maketerm(typeof(x), operation(x), [unwrap(t)], metadata(x))),
IsHistory, true)
end

Expand Down

0 comments on commit e183abf

Please sign in to comment.