Skip to content

Commit 4fcedea

Browse files
authored
Merge pull request #887 from SciML/symbolics_fixes
[WIP] Fix Symbolics related stuff
2 parents f6e847b + efa4b4e commit 4fcedea

20 files changed

+81
-79
lines changed

Project.toml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ Requires = "ae029012-a4dd-5104-9daa-d747884805df"
2222
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
2323
Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2424
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
25-
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
2625
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
2726
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2827

@@ -38,8 +37,8 @@ CatalystStructuralIdentifiabilityExtension = "StructuralIdentifiability"
3837

3938
[compat]
4039
BifurcationKit = "0.3"
41-
DataStructures = "0.18"
4240
Combinatorics = "1.0.2"
41+
DataStructures = "0.18"
4342
DiffEqBase = "6.83.0"
4443
DocStringExtensions = "0.8, 0.9"
4544
DynamicPolynomials = "0.5"
@@ -50,15 +49,14 @@ JumpProcesses = "9.3.2"
5049
LaTeXStrings = "1.3.0"
5150
Latexify = "0.14, 0.15, 0.16"
5251
MacroTools = "0.5.5"
53-
ModelingToolkit = "9.11.0"
52+
ModelingToolkit = "9.16.0"
5453
Parameters = "0.12"
5554
Reexport = "0.2, 1.0"
5655
Requires = "1.0"
5756
RuntimeGeneratedFunctions = "0.5.12"
5857
Setfield = "1"
59-
StructuralIdentifiability = "0.5.1"
60-
SymbolicUtils = "1.0.3"
61-
Symbolics = "5.27"
58+
StructuralIdentifiability = "0.5.8"
59+
Symbolics = "5.30.1"
6260
Unitful = "1.12.4"
6361
julia = "1.10"
6462

docs/Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ IncompleteLU = "0.2"
5151
JumpProcesses = "9.11"
5252
Latexify = "0.16"
5353
LinearSolve = "2.30"
54-
ModelingToolkit = "9.15"
54+
ModelingToolkit = "9.16.0"
5555
NonlinearSolve = "3.12"
5656
Optim = "1.9"
5757
Optimization = "3.25"
@@ -68,5 +68,5 @@ SpecialFunctions = "2.4"
6868
StaticArrays = "1.9"
6969
SteadyStateDiffEq = "2.2"
7070
StochasticDiffEq = "6.65"
71-
StructuralIdentifiability = "0.5.7"
72-
Symbolics = "5.28"
71+
StructuralIdentifiability = "0.5.8"
72+
Symbolics = "5.30.1"

ext/CatalystHomotopyContinuationExtension.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import DynamicPolynomials
66
import ModelingToolkit as MT
77
import HomotopyContinuation as HC
88
import Setfield: @set
9-
import Symbolics: unwrap, wrap, Rewriters, symtype, issym, istree
9+
import Symbolics: unwrap, wrap, Rewriters, symtype, issym
10+
using Symbolics: iscall
1011

1112
# Creates and exports hc_steady_states function.
1213
include("CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl")

ext/CatalystHomotopyContinuationExtension/homotopy_continuation_extension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ end
8080
# If the input is a fraction, removes the denominator.
8181
function remove_denominators(expr)
8282
s_expr = simplify_fractions(expr)
83-
!istree(expr) && return expr
83+
!iscall(expr) && return expr
8484
if operation(s_expr) == /
8585
return remove_denominators(arguments(s_expr)[1])
8686
end

ext/CatalystStructuralIdentifiabilityExtension/structural_identifiability_extension.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ function SI.assess_local_identifiability(rs::ReactionSystem, args...;
7373
funcs_to_check = make_ftc(funcs_to_check, conseqs, vars)
7474

7575
# Computes identifiability and converts it to a easy to read form.
76-
out = SI.assess_local_identifiability(sys, args...; measured_quantities,
76+
out = SI.assess_local_identifiability(osys, args...; measured_quantities,
7777
funcs_to_check, kwargs...)
7878
return make_output(out, funcs_to_check, reverse.(conseqs))
7979
end

src/Catalyst.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ using RuntimeGeneratedFunctions
2323
RuntimeGeneratedFunctions.init(@__MODULE__)
2424

2525
import Symbolics: BasicSymbolic
26-
import SymbolicUtils
27-
using ModelingToolkit: Symbolic, value, istree, get_unknowns, get_ps, get_iv, get_systems,
26+
using Symbolics: iscall
27+
using ModelingToolkit: Symbolic, value, get_unknowns, get_ps, get_iv, get_systems,
2828
get_eqs, get_defaults, toparam, get_var_to_name, get_observed,
2929
getvar
3030

@@ -44,6 +44,7 @@ import Graphs: DiGraph, SimpleGraph, SimpleDiGraph, vertices, edges, add_vertice
4444
import DataStructures: OrderedDict, OrderedSet
4545
import Parameters: @with_kw_noshow
4646
import Symbolics: occursin, wrap
47+
import Symbolics.RewriteHelpers: hasnode, replacenode
4748

4849
# globals for the modulate
4950
function default_time_deriv()

src/latexify_recipes.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function make_stoich_str(spec, stoich, subber; mathrm = true, kwargs...)
193193
if isequal(stoich, one(stoich))
194194
prestr * latexraw(subber(spec); kwargs...) * poststr
195195
else
196-
if (stoich isa Symbolic) && istree(stoich)
196+
if (stoich isa Symbolic) && iscall(stoich)
197197
LaTeXString("(") *
198198
latexraw(subber(stoich); kwargs...) *
199199
LaTeXString(")") *

src/reaction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ function print_rxside(io::IO, specs, stoich)
260260
spec : MT.operation(spec)
261261
if isequal(stoich[i], one(stoich[i]))
262262
print(io, prspec)
263-
elseif istree(stoich[i])
263+
elseif iscall(stoich[i])
264264
print(io, "(", stoich[i], ")*", prspec)
265265
else
266266
print(io, stoich[i], "*", prspec)

src/reactionsystem.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ function validate(rs::ReactionSystem, info::String = "")
14641464
# Needs additional checks because for cases: (1.0^n) and (1.0^n1)*(1.0^n2).
14651465
# These are not considered (be default) considered equal to `1.0` for unitless reactions.
14661466
isequal(rxunits, rateunits) && continue
1467-
if istree(rxunits)
1467+
if iscall(rxunits)
14681468
unitless_exp(rxunits) && continue
14691469
(operation(rxunits) == *) &&
14701470
all(unitless_exp(arg) for arg in arguments(rxunits)) && continue

src/reactionsystem_conversions.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ end
440440

441441
# Finds and differentials in an expression, and sets these to 0.
442442
function remove_diffs(expr)
443-
if Symbolics._occursin(Symbolics.is_derivative, expr)
444-
return Symbolics.replace(expr, diff_2_zero)
443+
if hasnode(Symbolics.is_derivative, expr)
444+
return replacenode(expr, diff_2_zero)
445445
else
446446
return expr
447447
end
@@ -556,8 +556,8 @@ function nonlinear_convert_differentials_check(rs::ReactionSystem)
556556
# If the lhs upper level function is not a differential w.r.t. time.
557557
# If the contenct of the differential is not a variable (and nothing more).
558558
# If either of this is a case, throws the warning.
559-
if Symbolics._occursin(Symbolics.is_derivative, eq.rhs) ||
560-
!Symbolics.istree(eq.lhs) ||
559+
if hasnode(Symbolics.is_derivative, eq.rhs) ||
560+
!Symbolics.is_derivative(eq.lhs) ||
561561
!isequal(Symbolics.operation(eq.lhs), Differential(get_iv(rs))) ||
562562
(length(arguments(eq.lhs)) != 1) ||
563563
!any(isequal(arguments(eq.lhs)[1]), nonspecies(rs))
@@ -892,7 +892,7 @@ function to_multivariate_poly(polyeqs::AbstractVector{Symbolics.BasicSymbolic{Re
892892

893893
pvar2sym, sym2term = SymbolicUtils.get_pvar2sym(), SymbolicUtils.get_sym2term()
894894
ps = map(polyeqs) do x
895-
if istree(x) && operation(x) == (/)
895+
if iscall(x) && operation(x) == (/)
896896
error("We should not be able to get here, please contact the package authors.")
897897
else
898898
PolyForm(x, pvar2sym, sym2term).p

0 commit comments

Comments
 (0)