Skip to content

Commit a7ed2a1

Browse files
committed
Add test for linear_extra_interpolation()
1 parent 29a3085 commit a7ed2a1

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

tests/test_tools.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from windpowerlib.tools import smallest_difference
1+
from windpowerlib.tools import smallest_difference, linear_extra_interpolation
22
import pandas as pd
3+
from pandas.util.testing import assert_series_equal
34

45

56
class TestTools:
@@ -27,3 +28,32 @@ def test_smallest_difference(self):
2728
expected_output = (100, 4.0)
2829
parameters['comp_value'] = 90
2930
assert smallest_difference(**parameters) == expected_output
31+
32+
def test_linear_extra_interpolation(self):
33+
weather = pd.DataFrame(data={'v_wind': [4.0, 5.0, 6.0]},
34+
index=[100, 150, 200])
35+
weather_pd_series = pd.DataFrame(data={'v_wind': [
36+
pd.Series(data=[4.0, 5.0, 6.0]),
37+
pd.Series(data=[8.0, 10.0, 14.0]),
38+
pd.Series(data=[16.0, 20.0, 28.0])]}, index=[100, 150, 200])
39+
# TODO: test v_wind as np.array
40+
41+
# Entries in column v_wind are float
42+
expected_output = 4.0
43+
assert (linear_extra_interpolation(weather, 100, 'v_wind') ==
44+
expected_output)
45+
expected_output = 5.5
46+
assert (linear_extra_interpolation(weather, 175, 'v_wind') ==
47+
expected_output)
48+
expected_output = 7.0
49+
assert (linear_extra_interpolation(weather, 250, 'v_wind') ==
50+
expected_output)
51+
expected_output = 3.0
52+
assert (linear_extra_interpolation(weather, 50, 'v_wind') ==
53+
expected_output)
54+
55+
# Entries in column v_wind are pd.Series
56+
expected_output = pd.Series(data=[4.0, 5.0, 6.0])
57+
assert_series_equal(linear_extra_interpolation(weather_pd_series,
58+
100, 'v_wind'),
59+
expected_output)

0 commit comments

Comments
 (0)