Skip to content

Commit

Permalink
Merge pull request #56 from ChrisRackauckas/patch-1
Browse files Browse the repository at this point in the history
Allow SciMLBase v2
  • Loading branch information
augustinas1 authored Sep 26, 2023
2 parents a2717c7 + e6644ff commit b2bfc86
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "MomentClosure"
uuid = "01a1b25a-ecf0-48c5-ae58-55bfd5393600"
authors = ["Augustinas Sukys"]
version = "0.3.0"
version = "0.3.1"

[deps]
Catalyst = "479239e8-5488-4da2-87a7-35f2df7eef83"
Expand All @@ -27,7 +27,7 @@ Distributions = "0.25"
DocStringExtensions = "0.8, 0.9"
Latexify = "0.15.14, 0.16"
ModelingToolkit = "8"
SciMLBase = "1.8.3"
SciMLBase = "1.8.3, 2"
SymbolicUtils = "1"
Symbolics = "5"
TupleTools = "1.2.0"
Expand Down
3 changes: 2 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ makedocs(;
repo="https://github.com/augustinas1/MomentClosure.jl/blob/{commit}{path}#L{line}",
sitename="MomentClosure.jl",
doctest=false,
warnonly = [:docs_block, :missing_docs, :cross_references],
format=Documenter.HTML(;
mathengine=Documenter.Writers.HTMLWriter.MathJax2(),
mathengine=Documenter.Writers.HTMLWriter.MathJax3(),
prettyurls=get(ENV, "CI", "false") == "true",
canonical="https://augustinas1.github.io/MomentClosure.jl",
assets=String[],
Expand Down
8 changes: 6 additions & 2 deletions test/basic_symbolic_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ fcs, pwrs, mpwr = polynomial_propensities([expr], t, smap)

expr = x*(x^2+y) / (c+2)
fcs, pwrs, mpwr = polynomial_propensities([expand(expr)], t, smap)
@test all(isequal.(fcs[1], [1 / (2 + c), 1 / (2 + c)])) && pwrs[1] == [[3, 0], [1, 1]] && mpwr == 3
@test mpwr == 3 &&
all(isequal.(fcs[1], [1 / (2 + c), 1 / (2 + c)])) &&
( pwrs[1] == [[3, 0], [1, 1]] || pwrs[1] == [[1, 1], [3, 0]] )

expr = c^2*x + y / c
fcs, pwrs, mpwr = polynomial_propensities([expr], t, smap)
@test all(isequal.(fcs[1], [c^2, 1 / c])) && pwrs[1] == [[1, 0], [0, 1]] && mpwr == 1
@test mpwr == 1 &&
( all(isequal.(fcs[1], [1 / c, c^2])) || all(isequal.(fcs[1], [c^2, 1 / c])) ) &&
( pwrs[1] == [[0, 1], [1, 0]] || pwrs[1] == [[1, 0], [0, 1]] )

expr = x / (y+1)
@test_throws ErrorException polynomial_propensities([expr], t, smap)
25 changes: 6 additions & 19 deletions test/latexify_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,21 @@ clean_eqs = bernoulli_moment_eqs(raw_eqs, binary_vars)
closed_raw_eqs = moment_closure(raw_eqs, "conditional gaussian", binary_vars)

# latexify output is very sensitive to Julia version and latexify + Symbolics updates...
# NOTE: implementing a lazy test to avoid that
#=
expr = replace(raw"\begin{align*}
\frac{d\mu_{1 0}}{dt} =& k_{on} - k_{on} \mu_{1 0} - k_{off} \mu_{1 2} \\
\frac{d\mu_{0 1}}{dt} =& k_{p} p^{-1} \mu_{1 0} - \gamma_{p} \mu_{0 1} - k_{p} \mu_{1 0} \\
\frac{d\mu_{1 1}}{dt} =& k_{on} \mu_{0 1} + k_{p} p^{-1} \mu_{1 0} - k_{p} \mu_{1 0} - k_{off} \mu_{1 3} - k_{on} \mu_{1 1} - \gamma_{p} \mu_{1 1} \\
\frac{d\mu_{0 2}}{dt} =& \gamma_{p} \mu_{0 1} + k_{p} \mu_{1 0} + 2 k_{p} p^{-2} \mu_{1 0} + 2 k_{p} p^{-1} \mu_{1 1} - 2 k_{p} \mu_{1 1} - 2 \gamma_{p} \mu_{0 2} - 3 k_{p} p^{-1} \mu_{1 0}
\end{align*}
", "\r\n"=>"\n")
exprl = latexify(clean_eqs)
@test exprl == expr1 || exprl == expr2
=#
expr = replace(raw"\begin{align*}
\frac{d\mu_{1 0}}{dt} =& k_{on}", "\r\n"=>"\n")
@test latexify(clean_eqs)[1:46] == expr

#=
expr = replace(raw"\begin{align*}
\mu_{1 2} =& \mu_{1 0}^{-1} \mu_{1 1}^{2} \\
\mu_{1 3} =& 3 \mu_{1 0}^{-1} \mu_{1 1} \mu_{1 2} - 2 \mu_{1 0}^{-2} \mu_{1 1}^{3}
expr1 = replace(raw"\begin{align*}
\mu_{1 2} =& \frac{\mu_{1 1}^{2}}{\mu_{1 0}} \\
\mu_{1 3} =& \frac{3 \mu_{1 2} \mu_{1 1}}{\mu_{1 0}} + \frac{-2 \mu_{1 1}^{3}}{\mu_{1 0}^{2}}
\end{align*}
", "\r\n"=>"\n")
=#
expr = replace(raw"\begin{align*}
expr2 = replace(raw"\begin{align*}
\mu_{1 2} =& \frac{\mu_{1 1}^{2}}{\mu_{1 0}} \\
\mu_{1 3} =& \frac{-2 \mu_{1 1}^{3}}{\mu_{1 0}^{2}} + \frac{3 \mu_{1 1} \mu_{1 2}}{\mu_{1 0}}
\end{align*}
", "\r\n"=>"\n")
@test latexify(closed_raw_eqs, :closure) == expr
exprl = latexify(closed_raw_eqs, :closure)
@test (exprl == expr1) || (exprl == expr2)

@test_throws MethodError latexify(raw_eqs, :closure)

0 comments on commit b2bfc86

Please sign in to comment.