|
7 | 7 |
|
8 | 8 | class TestTools: |
9 | 9 |
|
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 | + """ |
17 | 23 | exp_output = pd.Series(data=[4.0, 5.0, 6.0]) |
18 | 24 | 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 | + """ |
22 | 32 | exp_output = pd.Series(data=[4.5, 6.5, 8.0]) |
23 | | - parameters['target_height'] = 140 |
| 33 | + self.parameters['target_height'] = 140 |
24 | 34 | assert_series_equal(linear_interpolation_extrapolation( |
25 | | - df, **parameters), exp_output) |
| 35 | + self.df, **self.parameters), exp_output) |
| 36 | + |
26 | 37 | exp_output = pd.Series(data=[4.285714, 5.428571, 6.428571]) |
27 | | - parameters['target_height'] = 90 |
| 38 | + self.parameters['target_height'] = 90 |
28 | 39 | 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 | + """ |
32 | 47 | exp_output = pd.Series(data=[5.333333, 9.0, 11.333333]) |
33 | | - parameters['target_height'] = 240 |
| 48 | + self.parameters['target_height'] = 240 |
34 | 49 | 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 | + """ |
38 | 57 | exp_output = pd.Series(data=[1.857143, 1.785714, 2.785714]) |
39 | | - parameters['target_height'] = 5 |
| 58 | + self.parameters['target_height'] = 5 |
40 | 59 | assert_series_equal(linear_interpolation_extrapolation( |
41 | | - df, **parameters), exp_output) |
| 60 | + self.df, **self.parameters), exp_output) |
42 | 61 |
|
43 | 62 | def test_logarithmic_interpolation_extrapolation(self): |
44 | 63 | parameters = {'target_height': 80} |
|
0 commit comments