-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2229e2d
commit 86119ff
Showing
2 changed files
with
175 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Test suite for hydrological modelling in hydrological_modelling.py""" | ||
import unittest | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from xhydro.modelling.hydrological_modelling import hydrological_model_selector | ||
|
||
|
||
def test_hydrological_modelling(): | ||
"""Test the hydrological models as they become online""" | ||
|
||
# Test the dummy model | ||
model_config = { | ||
"precip": np.array([10, 11, 12, 13, 14, 15]), | ||
"temperature": np.array([10, 3, -5, 1, 15, 0]), | ||
"Qobs": np.array([120, 130, 140, 150, 160, 170]), | ||
"drainage_area": np.array([10]), | ||
"model_name": "Dummy", | ||
"parameters": np.array([5, 5, 5]), | ||
} | ||
Qsim = hydrological_model_selector(model_config) | ||
assert Qsim[3] == 3500.00 | ||
|
||
# Test the exceptions for new models | ||
model_config.update(model_name="ADD_OTHER_HERE") | ||
Qsim = hydrological_model_selector(model_config) | ||
assert Qsim == 0 | ||
|
||
|
||
@pytest.mark.xfail(raises=NotImplementedError) | ||
def import_unknown_model(): | ||
model_config = {"model_name": "fake_model"} | ||
Qsim = hydrological_model_selector(model_config) | ||
assert Qsim == None |