Skip to content

Commit ceb34cb

Browse files
committed
Restructure and add tests to test_rho_hub
1 parent f761f05 commit ceb34cb

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

tests/test_modelchain.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,37 @@ def test_rho_hub(self):
101101
data_height = {'temp_air': 2,
102102
'temp_air_2': 10,
103103
'pressure': 0}
104-
# Test with above conditions
104+
105+
# temp_air_2 is closer to hub height than temp_air # TODO: Add test for temp_air is closer to hub height than temp_air_2
105106
rho_exp = pd.Series(data=[1.30617, 1.29966])
106-
assert_series_equal(self.test_mc.rho_hub(weather,
107-
data_height), rho_exp)
107+
assert_series_equal(test_mc.rho_hub(weather, data_height), rho_exp)
108+
assert_series_equal(test_mc.rho_hub(weather_df, data_height), rho_exp)
109+
rho_exp = np.array([1.30616958, 1.29965556])
110+
assert_allclose(test_mc.rho_hub(weather_arr, data_height), rho_exp)
111+
rho_exp = pd.Series(data=[1.30309, 1.42707])
112+
assert_series_equal(test_mc_2.rho_hub(weather, data_height), rho_exp)
113+
assert_series_equal(test_mc_2.rho_hub(weather_df, data_height),
114+
rho_exp)
115+
rho_exp = np.array([1.30309439, 1.42706674])
116+
assert_allclose(test_mc_2.rho_hub(weather_arr, data_height), rho_exp)
117+
108118
# temp_air at hub height
109119
rho_exp = pd.Series(data=[1.30305, 1.29657])
110120
data_height['temp_air'] = 100
111-
assert_series_equal(self.test_mc.rho_hub(weather,
112-
data_height), rho_exp)
121+
assert_series_equal(test_mc.rho_hub(weather, data_height), rho_exp)
122+
assert_series_equal(test_mc.rho_hub(weather_df, data_height), rho_exp)
123+
rho_exp = np.array([1.30305336, 1.29656645])
124+
assert_allclose(test_mc.rho_hub(weather_arr, data_height), rho_exp)
125+
113126
# temp_air_2 at hub height
114-
rho_exp = pd.Series(data=[1.30305, 1.30632])
127+
rho_exp = pd.Series(data=[1.30309, 1.30636])
115128
data_height['temp_air'] = 2
116129
data_height['temp_air_2'] = 100
117-
assert_series_equal(self.test_mc.rho_hub(weather,
118-
data_height), rho_exp)
119-
# Test weather as DataFrame
120-
assert_series_equal(self.test_mc.rho_hub(weather_df,
121-
data_height),
130+
assert_series_equal(test_mc_2.rho_hub(weather, data_height), rho_exp)
131+
assert_series_equal(test_mc_2.rho_hub(weather_df, data_height),
122132
rho_exp)
123-
# Test weather dictionary with numpy.arrays
124-
rho_exp = np.array([1.30305336, 1.30631507])
125-
assert_allclose(self.test_mc.rho_hub(weather_arr, data_height),
126-
rho_exp)
133+
rho_exp = np.array([1.30309439, 1.30635621])
134+
assert_allclose(test_mc_2.rho_hub(weather_arr, data_height), rho_exp)
127135

128136
def test_run_model(self):
129137
weather = {'temp_air': pd.Series(data=[267, 268]),

0 commit comments

Comments
 (0)