Skip to content

Commit ab5a959

Browse files
committed
up
1 parent 1cf743c commit ab5a959

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

test/miscellaneous_tests/units.jl

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ using ModelingToolkit: get_iv, get_unit, validate, ValidationError
1111
let
1212
# Creates a `ReactionSystem` programmatically, while designating units.
1313
@variables t [unit=u"s"]
14-
@species A(t) [unit=u"μM"] B(t) [unit=u"μM"] C(t) [unit=u"μM"]
15-
@parameters k1 [unit=u"μM/s"] k2 [unit=u"s"^(-1)] k3 [unit=u"μM*s"^(-1)]
14+
@species A(t) [unit=u"m"] B(t) [unit=u"m"] C(t) [unit=u"m"]
15+
@parameters k1 [unit=u"m/s"] k2 [unit=u"s"^(-1)] k3 [unit=u"m*s"^(-1)]
1616
rxs = [Reaction(k1, nothing, [A]),
1717
Reaction(k2, [A], [B]),
1818
Reaction(k3, [A, B], [B], [1, 1], [2])]
@@ -22,9 +22,9 @@ let
2222

2323
# Test that all reactions have the correct unit.
2424
for rx in reactions(rs)
25-
@test get_unit(oderatelaw(rx)) == u"μM/s"
25+
@test get_unit(oderatelaw(rx)) == u"m/s"
2626
# we don't currently convert units, so they will be the same as for ODEs
27-
@test get_unit(jumpratelaw(rx)) == u"μM/s"
27+
@test get_unit(jumpratelaw(rx)) == u"m/s"
2828
end
2929

3030
# Tests that the system can be converted to MTK systems without warnings.
@@ -34,7 +34,7 @@ let
3434
@test_nowarn convert(NonlinearSystem, rs)
3535

3636
# Tests that creating `Reaction`s with non-matching units yields warnings.
37-
@species B(t) [unit=u"μM"] D(t) [unit=u"g"]
37+
@species B(t) [unit=u"m"] D(t) [unit=u"kg"]
3838
bad_rx1 = Reaction(k1, [A], [D])
3939
bad_rx2 = Reaction(k1, [A], [B, D])
4040
bad_rx3 = Reaction(k1, [A, D], [B])
@@ -55,7 +55,7 @@ let
5555
@test (@test_logs (:warn, ) match_mode=:any validate(bad_rx8)) == false
5656

5757
# Tests that creating systems with non-matching units yields warnings.
58-
@parameters k2 [unit=u"g"]
58+
@parameters k2 [unit=u"kg"]
5959
bad_rxs = [
6060
Reaction(k2, nothing, [A]),
6161
Reaction(k2, [A], [B]),
@@ -71,14 +71,14 @@ begin
7171
rs = @reaction_network begin
7272
@ivs t [unit=u"s"]
7373
@species begin
74-
A(t), [unit=u"μM"]
75-
B(t), [unit=u"μM"]
76-
C(t), [unit=u"μM"]
74+
A(t), [unit=u"m"]
75+
B(t), [unit=u"m"]
76+
C(t), [unit=u"m"]
7777
end
7878
@parameters begin
79-
k1, [unit=u"μM/s"]
79+
k1, [unit=u"m/s"]
8080
k2, [unit=u"s"^(-1)]
81-
k3, [unit=u"μM*s"^(-1)]
81+
k3, [unit=u"m*s"^(-1)]
8282
end
8383
k1, 0 --> A
8484
k2, A --> B
@@ -87,26 +87,26 @@ begin
8787

8888
# Checks that the `ReactionSystem`'s content have the correct units.
8989
@test get_unit(get_iv(rs)) == u"s"
90-
@test all(get_unit.([rs.A, rs.B, rs.C]) .== [u"μM", u"μM", u"μM"])
91-
@test all(get_unit.([rs.k1, rs.k2, rs.k3]) .== [u"μM/s", u"s"^(-1), u"μM*s"^(-1)])
90+
@test all(get_unit.([rs.A, rs.B, rs.C]) .== [u"m", u"m", u"m"])
91+
@test all(get_unit.([rs.k1, rs.k2, rs.k3]) .== [u"m/s", u"s"^(-1), u"m*s"^(-1)])
9292
for rx in reactions(rs)
93-
@test get_unit(oderatelaw(rx)) == u"μM/s"
93+
@test get_unit(oderatelaw(rx)) == u"m/s"
9494
# we don't currently convert units, so they will be the same as for ODEs
95-
@test get_unit(jumpratelaw(rx)) == u"μM/s"
95+
@test get_unit(jumpratelaw(rx)) == u"m/s"
9696
end
9797

9898
# Checks that system declarations with erroneous units yields errors.
9999
@test_logs (:warn, ) match_mode=:any @reaction_network begin
100100
@ivs t [unit=u"1/s"] # Here, t's unit is wrong.
101101
@species begin
102-
A(t), [unit=u"μM"]
103-
B(t), [unit=u"μM"]
104-
C(t), [unit=u"μM"]
102+
A(t), [unit=u"m"]
103+
B(t), [unit=u"m"]
104+
C(t), [unit=u"m"]
105105
end
106106
@parameters begin
107-
k1, [unit=u"μM/s"]
107+
k1, [unit=u"m/s"]
108108
k2, [unit=u"s"^(-1)]
109-
k3, [unit=u"μM*s"^(-1)]
109+
k3, [unit=u"m*s"^(-1)]
110110
end
111111
k1, 0 --> A
112112
k2, A --> B
@@ -115,14 +115,14 @@ begin
115115
@test_logs (:warn, ) match_mode=:any @reaction_network begin
116116
@ivs t [unit=u"s"]
117117
@species begin
118-
A(t), [unit=u"μM"]
119-
B(t), [unit=u"μM"]
120-
C(t), [unit=u"μM"]
118+
A(t), [unit=u"m"]
119+
B(t), [unit=u"m"]
120+
C(t), [unit=u"m"]
121121
end
122122
@parameters begin
123-
k1, [unit=u"μM"] # Here, k1's unit is wrong.
123+
k1, [unit=u"m"] # Here, k1's unit is wrong.
124124
k2, [unit=u"s"^(-1)]
125-
k3, [unit=u"μM*s"^(-1)]
125+
k3, [unit=u"m*s"^(-1)]
126126
end
127127
k1, 0 --> A
128128
k2, A --> B
@@ -131,14 +131,14 @@ begin
131131
@test_logs (:warn, ) match_mode=:any @reaction_network begin
132132
@ivs t [unit=u"s"]
133133
@species begin
134-
A(t), [unit=u"μM*s"] # Here, A's unit is wrong.
135-
B(t), [unit=u"μM"]
136-
C(t), [unit=u"μM"]
134+
A(t), [unit=u"m*s"] # Here, A's unit is wrong.
135+
B(t), [unit=u"m"]
136+
C(t), [unit=u"m"]
137137
end
138138
@parameters begin
139-
k1, [unit=u"μM/s"]
139+
k1, [unit=u"m/s"]
140140
k2, [unit=u"s"^(-1)]
141-
k3, [unit=u"μM*s"^(-1)]
141+
k3, [unit=u"m*s"^(-1)]
142142
end
143143
k1, 0 --> A
144144
k2, A --> B
@@ -168,20 +168,20 @@ let
168168
@test_nowarn @reaction_network begin
169169
@ivs t [unit=u"s"]
170170
@species begin
171-
X1(t), [unit=u"μM"]
172-
Z1(t), [unit=u"μM"]
173-
X2(t), [unit=u"μM"]
174-
Z2(t), [unit=u"μM"]
175-
X3(t), [unit=u"μM"]
176-
Y3(t), [unit=u"μM"]
177-
Z3(t), [unit=u"μM"]
171+
X1(t), [unit=u"m"]
172+
Z1(t), [unit=u"m"]
173+
X2(t), [unit=u"m"]
174+
Z2(t), [unit=u"m"]
175+
X3(t), [unit=u"m"]
176+
Y3(t), [unit=u"m"]
177+
Z3(t), [unit=u"m"]
178178
end
179179
@parameters begin
180-
k1, [unit=u"μM^(-2)/s"]
181-
v2, [unit=u"μM^(-2)/s"]
182-
K2, [unit=u"μM"]
183-
v3, [unit=u"μM^(-1)/s"]
184-
K3, [unit=u"μM"]
180+
k1, [unit=u"m^(-2)/s"]
181+
v2, [unit=u"m^(-2)/s"]
182+
K2, [unit=u"m"]
183+
v3, [unit=u"m^(-1)/s"]
184+
K3, [unit=u"m"]
185185
n3
186186
end
187187
k1*X1, 2X1 --> Z1

0 commit comments

Comments
 (0)