Skip to content

Commit d065c63

Browse files
committed
make latex tests reference tests
1 parent f4fc281 commit d065c63

File tree

6 files changed

+25
-27
lines changed

6 files changed

+25
-27
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
8383
Optim = "429524aa-4258-5aef-a3af-852621145aeb"
8484
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
8585
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
86+
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
8687
SteadyStateDiffEq = "9672c7b4-1e72-59bd-8a11-6ac3964bc41f"
8788
StochasticDiffEq = "789caeaf-c7a9-5a7d-9973-96adeb23e2a0"
8889
Sundials = "c3572dad-4567-51f8-b174-8c6c989267f4"
8990
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
9091

9192
[targets]
92-
test = ["BenchmarkTools", "ForwardDiff", "GalacticOptim", "NonlinearSolve", "OrdinaryDiffEq", "Optim", "Random", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials"]
93+
test = ["BenchmarkTools", "ForwardDiff", "GalacticOptim", "NonlinearSolve", "OrdinaryDiffEq", "Optim", "Random", "ReferenceTests", "SteadyStateDiffEq", "Test", "StochasticDiffEq", "Sundials"]

test/latexify.jl

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Test
22
using Latexify
33
using ModelingToolkit
4+
using ReferenceTests
45

56
### Tips for generating latex tests:
67
### Latexify has an unexported macro:
@@ -28,46 +29,24 @@ eqs = [D(x) ~ σ*(y-x)*D(x-y)/D(z),
2829

2930

3031
# Latexify.@generate_test latexify(eqs)
31-
@test latexify(eqs) == replace(
32-
raw"\begin{align}
33-
\frac{dx(t)}{dt} =& \frac{\sigma \mathrm{\frac{d}{d t}}\left( x\left( t \right) - y\left( t \right) \right) \left( y\left( t \right) - x\left( t \right) \right)}{\frac{dz(t)}{dt}} \\
34-
0 =& - y\left( t \right) + 0.1 \sigma x\left( t \right) \left( \rho - z\left( t \right) \right) \\
35-
\frac{dz(t)}{dt} =& \left( y\left( t \right) \right)^{\frac{2}{3}} x\left( t \right) - \beta z\left( t \right)
36-
\end{align}
37-
", "\r\n"=>"\n")
32+
@test_reference "latexify/10.tex" latexify(eqs)
3833

3934
@variables u[1:3](t)
4035
@parameters p[1:3]
4136
eqs = [D(u[1]) ~ p[3]*(u[2]-u[1]),
4237
0 ~ p[2]*p[3]*u[1]*(p[1]-u[1])/10-u[2],
4338
D(u[3]) ~ u[1]*u[2]^(2//3) - p[3]*u[3]]
4439

45-
@test latexify(eqs) == replace(
46-
raw"\begin{align}
47-
\frac{du{_1}(t)}{dt} =& p{_3} \left( \mathrm{u{_2}}\left( t \right) - \mathrm{u{_1}}\left( t \right) \right) \\
48-
0 =& - \mathrm{u{_2}}\left( t \right) + 0.1 \mathrm{u{_1}}\left( t \right) p{_2} p{_3} \left( p{_1} - \mathrm{u{_1}}\left( t \right) \right) \\
49-
\frac{du{_3}(t)}{dt} =& \left( \mathrm{u{_2}}\left( t \right) \right)^{\frac{2}{3}} \mathrm{u{_1}}\left( t \right) - \mathrm{u{_3}}\left( t \right) p{_3}
50-
\end{align}
51-
", "\r\n"=>"\n")
40+
@test_reference "latexify/20.tex" latexify(eqs)
5241

5342
eqs = [D(u[1]) ~ p[3]*(u[2]-u[1]),
5443
D(u[2]) ~ p[2]*p[3]*u[1]*(p[1]-u[1])/10-u[2],
5544
D(u[3]) ~ u[1]*u[2]^(2//3) - p[3]*u[3]]
56-
@test latexify(eqs) == replace(
57-
raw"\begin{align}
58-
\frac{du{_1}(t)}{dt} =& p{_3} \left( \mathrm{u{_2}}\left( t \right) - \mathrm{u{_1}}\left( t \right) \right) \\
59-
\frac{du{_2}(t)}{dt} =& - \mathrm{u{_2}}\left( t \right) + 0.1 \mathrm{u{_1}}\left( t \right) p{_2} p{_3} \left( p{_1} - \mathrm{u{_1}}\left( t \right) \right) \\
60-
\frac{du{_3}(t)}{dt} =& \left( \mathrm{u{_2}}\left( t \right) \right)^{\frac{2}{3}} \mathrm{u{_1}}\left( t \right) - \mathrm{u{_3}}\left( t \right) p{_3}
61-
\end{align}
62-
", "\r\n"=>"\n")
6345

46+
@test_reference "latexify/30.tex" latexify(eqs)
6447
@parameters t
6548
@variables x(t)
6649
D = Differential(t)
6750
eqs = [D(x) ~ (1+cos(t))/(1+2*x)]
6851

69-
@test latexify(eqs) == replace(
70-
raw"\begin{align}
71-
\frac{dx(t)}{dt} =& \frac{\left( 1 + \cos\left( t \right) \right)}{\left( 1 + 2 x\left( t \right) \right)}
72-
\end{align}
73-
", "\r\n"=>"\n")
52+
@test_reference "latexify/40.tex" latexify(eqs)

test/latexify/10.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
\begin{align}
2+
\frac{dx(t)}{dt} =& \frac{\sigma \mathrm{\frac{d}{d t}}\left( x\left( t \right) - y\left( t \right) \right) \left( y\left( t \right) - x\left( t \right) \right)}{\frac{dz(t)}{dt}} \\
3+
0 =& - y\left( t \right) + 0.1 \sigma x\left( t \right) \left( \rho - z\left( t \right) \right) \\
4+
\frac{dz(t)}{dt} =& \left( y\left( t \right) \right)^{\frac{2}{3}} x\left( t \right) - \beta z\left( t \right)
5+
\end{align}

test/latexify/20.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
\begin{align}
2+
\frac{du{_1}(t)}{dt} =& p{_3} \left( \mathrm{u{_2}}\left( t \right) - \mathrm{u{_1}}\left( t \right) \right) \\
3+
0 =& - \mathrm{u{_2}}\left( t \right) + 0.1 \mathrm{u{_1}}\left( t \right) p{_2} p{_3} \left( p{_1} - \mathrm{u{_1}}\left( t \right) \right) \\
4+
\frac{du{_3}(t)}{dt} =& \left( \mathrm{u{_2}}\left( t \right) \right)^{\frac{2}{3}} \mathrm{u{_1}}\left( t \right) - \mathrm{u{_3}}\left( t \right) p{_3}
5+
\end{align}

test/latexify/30.tex

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
\begin{align}
2+
\frac{du{_1}(t)}{dt} =& p{_3} \left( \mathrm{u{_2}}\left( t \right) - \mathrm{u{_1}}\left( t \right) \right) \\
3+
\frac{du{_2}(t)}{dt} =& - \mathrm{u{_2}}\left( t \right) + 0.1 \mathrm{u{_1}}\left( t \right) p{_2} p{_3} \left( p{_1} - \mathrm{u{_1}}\left( t \right) \right) \\
4+
\frac{du{_3}(t)}{dt} =& \left( \mathrm{u{_2}}\left( t \right) \right)^{\frac{2}{3}} \mathrm{u{_1}}\left( t \right) - \mathrm{u{_3}}\left( t \right) p{_3}
5+
\end{align}

test/latexify/40.tex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
\begin{align}
2+
\frac{dx(t)}{dt} =& \frac{\left( 1 + \cos\left( t \right) \right)}{\left( 1 + 2 x\left( t \right) \right)}
3+
\end{align}

0 commit comments

Comments
 (0)