Skip to content

Commit 5cc0685

Browse files
committed
Separate some tool tests
1 parent 61572d8 commit 5cc0685

File tree

1 file changed

+41
-22
lines changed

1 file changed

+41
-22
lines changed

tests/test_tools.py

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,57 @@
77

88
class TestTools:
99

10-
def test_linear_interpolation_extrapolation(self):
11-
parameters = {'target_height': 80}
12-
df = pd.DataFrame(data={10: [2.0, 2.0, 3.0],
13-
80: [4.0, 5.0, 6.0],
14-
200: [5.0, 8.0, 10.0]},
15-
index=[0, 1, 2])
16-
# target_height is equal to height given in a column of the DataFrame
10+
@classmethod
11+
def setup_class(cls):
12+
cls.parameters = {'target_height': 80}
13+
cls.df = pd.DataFrame(data={10: [2.0, 2.0, 3.0],
14+
80: [4.0, 5.0, 6.0],
15+
200: [5.0, 8.0, 10.0]},
16+
index=[0, 1, 2])
17+
18+
def test_linear_target_height_is_equal_to_given_height(self):
19+
"""
20+
Test linear interpolation and extrapolation if target_height is equal
21+
to height given in a column of the DataFrame.
22+
"""
1723
exp_output = pd.Series(data=[4.0, 5.0, 6.0])
1824
assert_series_equal(linear_interpolation_extrapolation(
19-
df, **parameters), exp_output)
20-
# target_height is between heights given in the columns of the
21-
# DataFrame
25+
self.df, **self.parameters), exp_output)
26+
27+
def test_linear_target_height_is_between_given_heights(self):
28+
"""
29+
Test linear interpolation and extrapolation if target_height is between
30+
heights given in the columns of the DataFrame
31+
"""
2232
exp_output = pd.Series(data=[4.5, 6.5, 8.0])
23-
parameters['target_height'] = 140
33+
self.parameters['target_height'] = 140
2434
assert_series_equal(linear_interpolation_extrapolation(
25-
df, **parameters), exp_output)
35+
self.df, **self.parameters), exp_output)
36+
2637
exp_output = pd.Series(data=[4.285714, 5.428571, 6.428571])
27-
parameters['target_height'] = 90
38+
self.parameters['target_height'] = 90
2839
assert_series_equal(linear_interpolation_extrapolation(
29-
df, **parameters), exp_output)
30-
# target_height is greater than the heights given in the columns of the
31-
# DataFrame
40+
self.df, **self.parameters), exp_output)
41+
42+
def test_linear_target_height_is_greater_than_the_given_heights(self):
43+
"""
44+
Test linear interpolation and extrapolation if target_height is greater
45+
than the heights given in the columns of the DataFrame
46+
"""
3247
exp_output = pd.Series(data=[5.333333, 9.0, 11.333333])
33-
parameters['target_height'] = 240
48+
self.parameters['target_height'] = 240
3449
assert_series_equal(linear_interpolation_extrapolation(
35-
df, **parameters), exp_output)
36-
# target_height is smaller than the heights given in the columns of the
37-
# DataFrame
50+
self.df, **self.parameters), exp_output)
51+
52+
def test_linear_target_height_is_smaller_than_the_given_heights(self):
53+
"""
54+
Test linear interpolation and extrapolation if target_height is smaller
55+
than the heights given in the columns of the DataFrame
56+
"""
3857
exp_output = pd.Series(data=[1.857143, 1.785714, 2.785714])
39-
parameters['target_height'] = 5
58+
self.parameters['target_height'] = 5
4059
assert_series_equal(linear_interpolation_extrapolation(
41-
df, **parameters), exp_output)
60+
self.df, **self.parameters), exp_output)
4261

4362
def test_logarithmic_interpolation_extrapolation(self):
4463
parameters = {'target_height': 80}

0 commit comments

Comments
 (0)