diff --git a/deps/evalhyd b/deps/evalhyd index c0ed1559bb5c35ca883984a2952d6fce80d58b49..5edca4b512d4258dd44414f3aa5c7a81db7b6cef 160000 --- a/deps/evalhyd +++ b/deps/evalhyd @@ -1 +1 @@ -Subproject commit c0ed1559bb5c35ca883984a2952d6fce80d58b49 +Subproject commit 5edca4b512d4258dd44414f3aa5c7a81db7b6cef diff --git a/src/evalhyd-python.cpp b/src/evalhyd-python.cpp index 942e72b52525c7b27110e5c1c640cdc92a640f9e..3a778cdf3eb9381dd5f1b6a5a9918293cd5c6b7f 100644 --- a/src/evalhyd-python.cpp +++ b/src/evalhyd-python.cpp @@ -23,7 +23,7 @@ PYBIND11_MODULE(evalhyd, m) // deterministic evaluation m.def( - "evald", evalhyd::evald<xt::pytensor<double, 1>>, + "evald", evalhyd::evald<1>, R"pbdoc( Function to evaluate deterministic streamflow predictions. @@ -95,10 +95,11 @@ PYBIND11_MODULE(evalhyd, m) )pbdoc", py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"), 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( - "evald", evalhyd::evald<xt::pytensor<double, 2>>, + "evald", evalhyd::evald<2>, R"pbdoc( Function to evaluate deterministic streamflow predictions. @@ -170,7 +171,8 @@ PYBIND11_MODULE(evalhyd, m) )pbdoc", py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"), 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 diff --git a/tests/test_determinist.py b/tests/test_determinist.py index 3cc4a11b9719a34d6f116386d0caf90279085c1d..06444e7088c7dcfdbc147a223a9541c31ec0433b 100644 --- a/tests/test_determinist.py +++ b/tests/test_determinist.py @@ -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): def test_nan(self): @@ -122,6 +133,9 @@ if __name__ == '__main__': test_suite.addTests( test_loader.loadTestsFromTestCase(TestTransform) ) + test_suite.addTests( + test_loader.loadTestsFromTestCase(TestMasking) + ) test_suite.addTests( test_loader.loadTestsFromTestCase(TestMissingData) ) diff --git a/tests/test_probabilist.py b/tests/test_probabilist.py index a59c9b86a664a4d184cd23adc6d7fad0e0c774c2..a081c9b834e0c55708b50f6c5763ba3d9a4e829b 100644 --- a/tests/test_probabilist.py +++ b/tests/test_probabilist.py @@ -79,7 +79,7 @@ class TestDecomposition(unittest.TestCase): class TestMasking(unittest.TestCase): 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 numpy.testing.assert_almost_equal( evalhyd.evalp(_obs, _prd, ["QS"], t_msk=msk)[0],