Commit 90982101 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

update to latest evalhyd version

which includes a temporal masking functionality for deterministic
evaluation
No related merge requests found
Pipeline #38749 passed with stage
in 1 minute and 55 seconds
Showing with 22 additions and 6 deletions
+22 -6
Subproject commit c0ed1559bb5c35ca883984a2952d6fce80d58b49 Subproject commit 5edca4b512d4258dd44414f3aa5c7a81db7b6cef
...@@ -23,7 +23,7 @@ PYBIND11_MODULE(evalhyd, m) ...@@ -23,7 +23,7 @@ PYBIND11_MODULE(evalhyd, m)
// deterministic evaluation // deterministic evaluation
m.def( m.def(
"evald", evalhyd::evald<xt::pytensor<double, 1>>, "evald", evalhyd::evald<1>,
R"pbdoc( R"pbdoc(
Function to evaluate deterministic streamflow predictions. Function to evaluate deterministic streamflow predictions.
...@@ -95,10 +95,11 @@ PYBIND11_MODULE(evalhyd, m) ...@@ -95,10 +95,11 @@ PYBIND11_MODULE(evalhyd, m)
)pbdoc", )pbdoc",
py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"), py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"),
py::arg("transform")="none", py::arg("exponent")=1, py::arg("transform")="none", py::arg("exponent")=1,
py::arg("epsilon")=-9 py::arg("epsilon")=-9,
py::arg("t_msk") = xt::pytensor<bool, 1>({})
); );
m.def( m.def(
"evald", evalhyd::evald<xt::pytensor<double, 2>>, "evald", evalhyd::evald<2>,
R"pbdoc( R"pbdoc(
Function to evaluate deterministic streamflow predictions. Function to evaluate deterministic streamflow predictions.
...@@ -170,7 +171,8 @@ PYBIND11_MODULE(evalhyd, m) ...@@ -170,7 +171,8 @@ PYBIND11_MODULE(evalhyd, m)
)pbdoc", )pbdoc",
py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"), py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"),
py::arg("transform")="none", py::arg("exponent")=1, py::arg("transform")="none", py::arg("exponent")=1,
py::arg("epsilon")=-9 py::arg("epsilon")=-9,
py::arg("t_msk") = xt::pytensor<bool, 2>({0})
); );
// probabilistic evaluation // probabilistic evaluation
......
...@@ -85,6 +85,17 @@ class TestTransform(unittest.TestCase): ...@@ -85,6 +85,17 @@ class TestTransform(unittest.TestCase):
) )
class TestMasking(unittest.TestCase):
def test_masks(self):
msk = numpy.ones(_obs.shape, dtype=bool)
msk[..., :99] = False
numpy.testing.assert_almost_equal(
evalhyd.evald(_obs, _prd, ["NSE"], t_msk=msk)[0],
evalhyd.evald(_obs[..., 99:], _prd[..., 99:], ["NSE"])[0]
)
class TestMissingData(unittest.TestCase): class TestMissingData(unittest.TestCase):
def test_nan(self): def test_nan(self):
...@@ -122,6 +133,9 @@ if __name__ == '__main__': ...@@ -122,6 +133,9 @@ if __name__ == '__main__':
test_suite.addTests( test_suite.addTests(
test_loader.loadTestsFromTestCase(TestTransform) test_loader.loadTestsFromTestCase(TestTransform)
) )
test_suite.addTests(
test_loader.loadTestsFromTestCase(TestMasking)
)
test_suite.addTests( test_suite.addTests(
test_loader.loadTestsFromTestCase(TestMissingData) test_loader.loadTestsFromTestCase(TestMissingData)
) )
......
...@@ -79,7 +79,7 @@ class TestDecomposition(unittest.TestCase): ...@@ -79,7 +79,7 @@ class TestDecomposition(unittest.TestCase):
class TestMasking(unittest.TestCase): class TestMasking(unittest.TestCase):
def test_masks(self): def test_masks(self):
msk = numpy.ones((1, *_obs.shape), dtype=bool) msk = numpy.ones((_obs.shape[0], 1, _obs.shape[1]), dtype=bool)
msk[..., :99] = False msk[..., :99] = False
numpy.testing.assert_almost_equal( numpy.testing.assert_almost_equal(
evalhyd.evalp(_obs, _prd, ["QS"], t_msk=msk)[0], evalhyd.evalp(_obs, _prd, ["QS"], t_msk=msk)[0],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment