Skip to content

Commit 5275a1d

Browse files
committed
use iscall
1 parent 0a938b7 commit 5275a1d

10 files changed

+17
-13
lines changed

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Setfield = "efcf1570-3423-57d1-acb7-fd33fddbac46"
2323
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
2424
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
2525
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
26+
TermInterface = "8ea1fca8-c5ef-4a55-8b96-4e9afe9c9a3c"
2627
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"
2728

2829
[weakdeps]

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 TermInterface: 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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ end
6363
# Parses and expression and return a version where any exponents that are Float64 (but an int, like 2.0) are turned into Int64s.
6464
make_int_exps(expr) = wrap(Rewriters.Postwalk(Rewriters.PassThrough(___make_int_exps))(unwrap(expr))).val
6565
function ___make_int_exps(expr)
66-
!istree(expr) && return expr
66+
!iscall(expr) && return expr
6767
if (operation(expr) == ^)
6868
if isinteger(arguments(expr)[2])
6969
return arguments(expr)[1] ^ Int64(arguments(expr)[2])
@@ -76,7 +76,7 @@ end
7676
# If the input is a fraction, removes the denominator.
7777
function remove_denominators(expr)
7878
s_expr = simplify_fractions(expr)
79-
!istree(expr) && return expr
79+
!iscall(expr) && return expr
8080
if operation(s_expr) == /
8181
return remove_denominators(arguments(s_expr)[1])
8282
end

src/Catalyst.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ RuntimeGeneratedFunctions.init(@__MODULE__)
2424

2525
import Symbolics: BasicSymbolic
2626
import SymbolicUtils
27-
using ModelingToolkit: Symbolic, value, istree, get_unknowns, get_ps, get_iv, get_systems,
27+
using TermInterface: iscall
28+
using ModelingToolkit: Symbolic, value, get_unknowns, get_ps, get_iv, get_systems,
2829
get_eqs, get_defaults, toparam, get_var_to_name, get_observed,
2930
getvar
3031

src/latexify_recipes.jl

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

src/reaction.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ function print_rxside(io::IO, specs, stoich)
255255
spec : MT.operation(spec)
256256
if isequal(stoich[i], one(stoich[i]))
257257
print(io, prspec)
258-
elseif istree(stoich[i])
258+
elseif iscall(stoich[i])
259259
print(io, "(", stoich[i], ")*", prspec)
260260
else
261261
print(io, stoich[i], "*", prspec)

src/reactionsystem.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,7 +1443,7 @@ function validate(rs::ReactionSystem, info::String = "")
14431443
# Needs additional checks because for cases: (1.0^n) and (1.0^n1)*(1.0^n2).
14441444
# These are not considered (be default) considered equal to `1.0` for unitless reactions.
14451445
isequal(rxunits, rateunits) && continue
1446-
if istree(rxunits)
1446+
if iscall(rxunits)
14471447
unitless_exp(rxunits) && continue
14481448
(operation(rxunits) == *) && all(unitless_exp(arg) for arg in arguments(rxunits)) && continue
14491449
end
@@ -1456,4 +1456,4 @@ function validate(rs::ReactionSystem, info::String = "")
14561456
end
14571457

14581458
# Checks if a unit consist of exponents with base 1 (and is this unitless).
1459-
unitless_exp(u) = istree(u) && (operation(u) == ^) && (arguments(u)[1] == 1)
1459+
unitless_exp(u) = iscall(u) && (operation(u) == ^) && (arguments(u)[1] == 1)

src/reactionsystem_conversions.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ function nonlinear_convert_differentials_check(rs::ReactionSystem)
560560
# If the contenct of the differential is not a variable (and nothing more).
561561
# If either of this is a case, throws the warning.
562562
if Symbolics._occursin(Symbolics.is_derivative, eq.rhs) ||
563-
!Symbolics.istree(eq.lhs) ||
563+
!Symbolics.iscall(eq.lhs) ||
564564
!isequal(Symbolics.operation(eq.lhs), Differential(get_iv(rs))) ||
565565
(length(arguments(eq.lhs)) != 1) ||
566566
!any(isequal(arguments(eq.lhs)[1]), nonspecies(rs))
@@ -895,7 +895,7 @@ function to_multivariate_poly(polyeqs::AbstractVector{Symbolics.BasicSymbolic{Re
895895

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

src/registered_functions.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ expand_registered_functions(expr)
118118
Takes an expression, and expands registered function expressions. E.g. `mm(X,v,K)` is replaced with v*X/(X+K). Currently supported functions: `mm`, `mmr`, `hill`, `hillr`, and `hill`.
119119
"""
120120
function expand_registered_functions(expr)
121-
istree(expr) || return expr
121+
iscall(expr) || return expr
122122
args = arguments(expr)
123123
if operation(expr) == Catalyst.mm
124124
return args[2]*args[1]/(args[1] + args[3])

test/dsl/dsl_basic_model_construction.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
# Fetch packages.
44
using DiffEqBase, Catalyst, Random, Test
5-
using ModelingToolkit: operation, istree, get_unknowns, get_ps, get_eqs, get_systems,
5+
using ModelingToolkit: operation, get_unknowns, get_ps, get_eqs, get_systems,
66
get_iv, nameof
7+
using TermInterface: iscall
78

89
# Sets stable rng number.
910
using StableRNGs
@@ -22,7 +23,7 @@ function unpacksys(sys)
2223
get_eqs(sys), get_iv(sys), get_unknowns(sys), get_ps(sys), nameof(sys), get_systems(sys)
2324
end
2425

25-
opname(x) = istree(x) ? nameof(operation(x)) : nameof(x)
26+
opname(x) = iscall(x) ? nameof(operation(x)) : nameof(x)
2627
alleq(xs, ys) = all(isequal(x, y) for (x, y) in zip(xs, ys))
2728

2829
# Gets all the reactants in a set of equations.

0 commit comments

Comments
 (0)