From 1a81340574287caeef4400f935f591b34317c41f Mon Sep 17 00:00:00 2001 From: Thibault Hallouin <thibhlln@gmail.com> Date: Wed, 10 Aug 2022 12:04:42 +0200 Subject: [PATCH] update to latest evalhyd version version which adds "sites" axis to dimensions of thresholds and masks --- deps/evalhyd | 2 +- src/evalhyd-python.cpp | 7 ++----- tests/test_probabilist.py | 10 +++++----- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/deps/evalhyd b/deps/evalhyd index 9092406..0cb58bb 160000 --- a/deps/evalhyd +++ b/deps/evalhyd @@ -1 +1 @@ -Subproject commit 90924065cc6365f65e3b33214884eb352a01e913 +Subproject commit 0cb58bb553733c00eed1930b62b7636899819b54 diff --git a/src/evalhyd-python.cpp b/src/evalhyd-python.cpp index 1c2c2f7..9635b12 100644 --- a/src/evalhyd-python.cpp +++ b/src/evalhyd-python.cpp @@ -158,10 +158,6 @@ PYBIND11_MODULE(evalhyd, m) ); // probabilistic evaluation - py::list empty_1d; - py::list empty_2d; - empty_2d.append(py::list()); - m.def( "evalp", evalhyd::evalp, R"pbdoc( @@ -204,7 +200,8 @@ PYBIND11_MODULE(evalhyd, m) shape: [(sites, lead times, subsets, {quantiles,} {thresholds,} {components}), ...] )pbdoc", py::arg("q_obs"), py::arg("q_prd"), py::arg("metrics"), - py::arg("q_thr") = empty_1d, py::arg("t_msk") = empty_2d + py::arg("q_thr") = xt::pytensor<double, 2>({0}), + py::arg("t_msk") = xt::pytensor<bool, 3>({0}) ); #ifdef VERSION_INFO diff --git a/tests/test_probabilist.py b/tests/test_probabilist.py index 2f0b62a..89c2571 100644 --- a/tests/test_probabilist.py +++ b/tests/test_probabilist.py @@ -38,7 +38,7 @@ class TestMetrics(unittest.TestCase): } def test_threshold_metrics(self): - thr = [690, 534, 445] + thr = numpy.array([[690, 534, 445]]) for metric in self.expected_thr.keys(): with self.subTest(metric=metric): numpy.testing.assert_almost_equal( @@ -58,7 +58,7 @@ class TestMetrics(unittest.TestCase): class TestDecomposition(unittest.TestCase): def test_brier_calibration_refinement(self): - thr = [690, 534, 445] + thr = numpy.array([[690, 534, 445]]) bs, = evalhyd.evalp(_obs, _prd, ["BS"], thr) bs_crd, = evalhyd.evalp(_obs, _prd, ["BS_CRD"], thr) numpy.testing.assert_almost_equal( @@ -66,7 +66,7 @@ class TestDecomposition(unittest.TestCase): ) def test_brier_likelihood_base_rate(self): - thr = [690, 534, 445] + thr = numpy.array([[690, 534, 445]]) bs, = evalhyd.evalp(_obs, _prd, ["BS"], thr) bs_lbd, = evalhyd.evalp(_obs, _prd, ["BS_LBD"], thr) numpy.testing.assert_almost_equal( @@ -77,8 +77,8 @@ class TestDecomposition(unittest.TestCase): class TestMasking(unittest.TestCase): def test_masks(self): - msk = numpy.ones(_obs.shape, dtype=bool) - msk[:, :99] = False + msk = numpy.ones((1, *_obs.shape), dtype=bool) + msk[..., :99] = False numpy.testing.assert_almost_equal( evalhyd.evalp(_obs, _prd, ["QS"], t_msk=msk)[0], evalhyd.evalp(_obs[..., 99:], _prd[..., 99:], ["QS"])[0] -- GitLab