Skip to content

Commit 8651deb

Browse files
Auto-format code using pep8 (#297)
Co-authored-by: GitHub Actions <actions@github.com>
1 parent 1c09eca commit 8651deb

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/acom_music_box/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import numpy as np
44

55
# The possible units we can convert to and from
6-
# functions that do conversions update this dictionary for their units in
6+
# functions that do conversions update this dictionary for their units in
77
# the appropriate way
88
unit_conversions = {
99
'mol m-3': 0,
@@ -19,6 +19,7 @@
1919
'mol mol-1': 0
2020
}
2121

22+
2223
def extract_unit(data, key):
2324
"""Extract the value and unit from the key in data."""
2425
pattern = re.compile(rf'{key} \[(.+)\]')
@@ -203,6 +204,7 @@ def convert_from_number_density(data, output_unit, temperature, pressure):
203204
else:
204205
return data * conversion_factor
205206

207+
206208
def calculate_air_density(temperature, pressure):
207209
"""
208210
Calculate the air density in moles m-3

tests/unit/test_utils.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,19 +62,20 @@ def test_invalid_concentration():
6262
with pytest.raises(ValueError):
6363
convert_concentration(data, 'invalid_concentration', 298.15, 101325)
6464

65+
6566
@pytest.mark.parametrize("data, output_unit, temperature, pressure, expected",
66-
[
67-
(1, 'mol m-3', 298.15, 101325, 1),
68-
(1, 'mol cm-3', 298.15, 101325, 1e-6),
69-
(1, 'molec m-3', 298.15, 101325, 1 * 6.02214076e+23),
70-
(1, 'molec cm-3', 298.15, 101325, 1e-6 * 6.02214076e+23),
71-
(1, 'molecule m-3', 298.15, 101325, 1 * 6.02214076e+23),
72-
(1, 'molecule cm-3', 298.15, 101325, 1e-6 * 6.02214076e+23),
73-
(1, 'ppth', 298.15, 101325, 1e3 / calculate_air_density(298.15, 101325)),
74-
(1, 'ppm', 298.15, 101325, 1e6 / calculate_air_density(298.15, 101325)),
75-
(1, 'ppb', 298.15, 101325, 1e9 / calculate_air_density(298.15, 101325)),
76-
(1, 'ppt', 298.15, 101325, 1e12 / calculate_air_density(298.15, 101325)),
77-
(1, 'mol mol-1', 298.15, 101325, 1 / calculate_air_density(298.15, 101325)),
78-
])
67+
[
68+
(1, 'mol m-3', 298.15, 101325, 1),
69+
(1, 'mol cm-3', 298.15, 101325, 1e-6),
70+
(1, 'molec m-3', 298.15, 101325, 1 * 6.02214076e+23),
71+
(1, 'molec cm-3', 298.15, 101325, 1e-6 * 6.02214076e+23),
72+
(1, 'molecule m-3', 298.15, 101325, 1 * 6.02214076e+23),
73+
(1, 'molecule cm-3', 298.15, 101325, 1e-6 * 6.02214076e+23),
74+
(1, 'ppth', 298.15, 101325, 1e3 / calculate_air_density(298.15, 101325)),
75+
(1, 'ppm', 298.15, 101325, 1e6 / calculate_air_density(298.15, 101325)),
76+
(1, 'ppb', 298.15, 101325, 1e9 / calculate_air_density(298.15, 101325)),
77+
(1, 'ppt', 298.15, 101325, 1e12 / calculate_air_density(298.15, 101325)),
78+
(1, 'mol mol-1', 298.15, 101325, 1 / calculate_air_density(298.15, 101325)),
79+
])
7980
def test_convert_from_number_density(data, output_unit, temperature, pressure, expected):
80-
assert math.isclose(convert_from_number_density(data, output_unit, temperature, pressure), expected)
81+
assert math.isclose(convert_from_number_density(data, output_unit, temperature, pressure), expected)

0 commit comments

Comments
 (0)