Skip to content

Commit eaab5f6

Browse files
committed
Add test with and without Warning
1 parent 3444e07 commit eaab5f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/test_modelchain.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import windpowerlib.wind_turbine as wt
1313
import windpowerlib.modelchain as mc
14+
from windpowerlib.tools import WindpowerlibUserWarning
1415

1516

1617
class TestModelChain:
@@ -454,3 +455,20 @@ def test_heigths_as_string(self):
454455
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
455456
**test_modelchain)
456457
test_mc.run_model(string_weather)
458+
459+
def test_weather_with_nan_values(self, recwarn):
460+
"""Test warning if weather data contain nan values."""
461+
test_turbine = {'hub_height': 100,
462+
'rotor_diameter': 80,
463+
'turbine_type': 'E-126/4200'}
464+
nan_weather = self.weather_df.copy()
465+
nan_weather.loc[1, ("temperature", 10)] = np.nan
466+
test_modelchain = {'power_output_model': 'power_curve',
467+
'density_corr': True}
468+
test_mc = mc.ModelChain(wt.WindTurbine(**test_turbine),
469+
**test_modelchain)
470+
msg = "'temperature', 10"
471+
with pytest.warns(WindpowerlibUserWarning, match=msg):
472+
test_mc.run_model(nan_weather)
473+
test_mc.run_model(self.weather_df)
474+
assert len(recwarn) == 0

0 commit comments

Comments
 (0)