Skip to content

Commit 29167f5

Browse files
committed
Add failing test if data heights are of type string
1 parent 80019f7 commit 29167f5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/test_modelchain.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,3 +341,26 @@ def test_modelchain_with_power_coefficient_curve_as_dict(self):
341341
power_output_model='power_coefficient_curve')
342342
test_mc.run_model(self.weather_df)
343343
assert_series_equal(test_mc.power_output, power_output_exp)
344+
345+
def test_heigths_as_string(self):
346+
"""Test run_model if data heights are of type string."""
347+
test_turbine = {'hub_height': 100,
348+
'rotor_diameter': 80,
349+
'turbine_type': 'E-126/4200'}
350+
351+
# Convert data heights to str
352+
string_weather = self.weather_df.copy()
353+
string_weather.columns = pd.MultiIndex.from_arrays([
354+
string_weather.columns.get_level_values(0),
355+
string_weather.columns.get_level_values(1).astype(str)])
356+
357+
# Heights in the original DataFrame are of type np.int64
358+
assert isinstance(self.weather_df.columns.get_level_values(1)[0],
359+
np.int64)
360+
assert isinstance(string_weather.columns.get_level_values(1)[0], str)
361+
362+
test_modelchain = {'power_output_model': 'power_curve',
363+
'density_corr': True}
364+
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
365+
**test_modelchain)
366+
test_mc.run_model(string_weather)

0 commit comments

Comments
 (0)