Skip to content

Commit 9e7d373

Browse files
committed
shorten conditional logic
1 parent 4268cd3 commit 9e7d373

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/systems/reaction/reactionsystem.jl

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,12 @@ function assemble_drift(rs)
7979
for (spec,stoich) in rx.netstoich
8080
i = species_to_idx[spec]
8181
if iszero(eqs[i].rhs)
82-
Δspec = isone(stoich) ? rl : stoich * rl
83-
eqs[i] = Equation(eqs[i].lhs, Δspec)
82+
rhs = isone(stoich) ? rl : stoich * rl
8483
else
8584
Δspec = isone(abs(stoich)) ? rl : abs(stoich) * rl
86-
if stoich > zero(stoich)
87-
eqs[i] = Equation(eqs[i].lhs, eqs[i].rhs + Δspec)
88-
else
89-
eqs[i] = Equation(eqs[i].lhs, eqs[i].rhs - Δspec)
90-
end
85+
rhs = (stoich > zero(stoich)) ? (eqs[i].rhs + Δspec) : (eqs[i].rhs - Δspec)
9186
end
87+
eqs[i] = Equation(eqs[i].lhs, rhs)
9288
end
9389
end
9490
eqs

0 commit comments

Comments
 (0)