Skip to content

Commit

Permalink
Improve code with black
Browse files Browse the repository at this point in the history
  • Loading branch information
Felipe S. S. Schneider committed Nov 16, 2020
1 parent 16808b4 commit d510ad8
Show file tree
Hide file tree
Showing 4 changed files with 671 additions and 452 deletions.
40 changes: 23 additions & 17 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,25 +159,31 @@ def test_private_functions_work():
assert list(core._unparse_reactions([(((1, "A"),), ((1, "B"),), True)])) == [
"A -> B"
]
assert list(
core._unparse_reactions(
[
(((2, "A"),), ((3, "B"),), True),
(((1, "A"),), ((2, "C"),), True),
(((50, "A"),), ((1, "D"),), True),
]
assert (
list(
core._unparse_reactions(
[
(((2, "A"),), ((3, "B"),), True),
(((1, "A"),), ((2, "C"),), True),
(((50, "A"),), ((1, "D"),), True),
]
)
)
) == ["2 A -> 3 B", "A -> 2 C", "50 A -> D"]
assert list(
core._unparse_reactions(
[
(((1, "E"), (1, "S")), ((1, "ES"),), True),
(((1, "ES"),), ((1, "E"), (1, "S")), True),
(((1, "ES"),), ((1, "ES‡"),), False),
(((1, "ES‡"),), ((1, "E"), (1, "P")), False),
]
== ["2 A -> 3 B", "A -> 2 C", "50 A -> D"]
)
assert (
list(
core._unparse_reactions(
[
(((1, "E"), (1, "S")), ((1, "ES"),), True),
(((1, "ES"),), ((1, "E"), (1, "S")), True),
(((1, "ES"),), ((1, "ES‡"),), False),
(((1, "ES‡"),), ((1, "E"), (1, "P")), False),
]
)
)
) == ["E + S -> ES", "ES -> E + S", "ES -> ES‡", "ES‡ -> E + P"]
== ["E + S -> ES", "ES -> E + S", "ES -> ES‡", "ES‡ -> E + P"]
)

assert list(
core._unparse_reactions(
Expand Down
34 changes: 20 additions & 14 deletions tests/test_rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,27 @@ def test_liquid_viscosities_are_correct():

def test_conversion_of_rate_constants_work():
"""Ensure converting reaction rate constants work."""
assert rates.convert_rate_constant(
12345e5,
"cm3 mol-1 s-1",
"l mol-1 s-1",
molecularity=2,
temperature=[200, 298.15, 300, 400],
) == pytest.approx(12345e8)
assert (
rates.convert_rate_constant(
12345e5,
"cm3 mol-1 s-1",
"l mol-1 s-1",
molecularity=2,
temperature=[200, 298.15, 300, 400],
)
== pytest.approx(12345e8)
)

assert rates.convert_rate_constant(
12345e10,
"cm3 particle-1 s-1",
"atm-1 s-1",
molecularity=2,
temperature=[200, 298.15, 300, 400],
) == pytest.approx(13.63e-23 * 12345e10 * np.array([200, 298.15, 300, 400]), 1e-3)
assert (
rates.convert_rate_constant(
12345e10,
"cm3 particle-1 s-1",
"atm-1 s-1",
molecularity=2,
temperature=[200, 298.15, 300, 400],
)
== pytest.approx(13.63e-23 * 12345e10 * np.array([200, 298.15, 300, 400]), 1e-3)
)


def test_conversion_rates_know_about_reaction_order():
Expand Down
Loading

0 comments on commit d510ad8

Please sign in to comment.