From 645511027846c82fed21e56938f25a00c97c067e Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Tue, 8 Apr 2025 13:13:10 +0200 Subject: [PATCH 01/31] add a new variable q_lvl to get the level of quantiles --- .../evalhyd/detail/probabilist/evaluator.hpp | 8 ++++-- .../evalhyd/detail/probabilist/intervals.hpp | 28 +++++++++++++++++-- .../evalhyd/detail/probabilist/quantiles.hpp | 15 ++++++++-- include/evalhyd/evalp.hpp | 4 ++- 4 files changed, 46 insertions(+), 9 deletions(-) diff --git a/include/evalhyd/detail/probabilist/evaluator.hpp b/include/evalhyd/detail/probabilist/evaluator.hpp index 3f94fd6..619104e 100644 --- a/include/evalhyd/detail/probabilist/evaluator.hpp +++ b/include/evalhyd/detail/probabilist/evaluator.hpp @@ -36,6 +36,7 @@ namespace evalhyd // members for optional input data const XD2& _q_thr; const xt::xtensor<double, 1>& _c_lvl; + const xt::xtensor<double, 1>& _q_lvl; xtl::xoptional<const std::string, bool> _events; xt::xtensor<bool, 4> t_msk; const std::vector<xt::xkeep_slice<int>>& b_exp; @@ -336,7 +337,7 @@ namespace evalhyd if (!itv_bnds.has_value()) { itv_bnds = elements::calc_itv_bnds( - q_prd, get_c_lvl(), + q_prd, get_c_lvl(), _q_lvl, n_sit, n_ldt, n_itv, n_tim ); } @@ -393,7 +394,7 @@ namespace evalhyd if (!qs.has_value()) { qs = intermediate::calc_qs( - q_obs, get_q_qnt(), n_mbr + q_obs, get_q_qnt(), n_mbr, _q_lvl ); } return qs.value(); @@ -482,12 +483,13 @@ namespace evalhyd const XD4& prd, const XD2& thr, const xt::xtensor<double, 1>& lvl, + const xt::xtensor<double, 1>& qlvl, xtl::xoptional<const std::string&, bool> events, const XB4& msk, const std::vector<xt::xkeep_slice<int>>& exp, const long int seed) : q_obs{obs}, q_prd{prd}, - _q_thr{thr}, _c_lvl{lvl}, _events{events}, + _q_thr{thr}, _c_lvl{lvl}, _q_lvl{qlvl}, _events{events}, t_msk(msk), b_exp(exp), random_seed{seed} { diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index adbd487..21316f2 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -44,6 +44,7 @@ namespace evalhyd inline xt::xtensor<double, 5> calc_itv_bnds( const XD4& q_prd, const xt::xtensor<double, 1>& c_lvl, + const xt::xtensor<double, 1>& q_lvl, std::size_t n_sit, std::size_t n_ldt, std::size_t n_itv, @@ -60,15 +61,38 @@ namespace evalhyd xt::col(quantiles, 0) = 0.5 - c_lvl / 200.; xt::col(quantiles, 1) = 0.5 + c_lvl / 200.; - // compute predictive interval bounds from quantiles - for (std::size_t i = 0; i < n_itv; i++) + // get or compute predictive interval bounds from quantiles + if (q_lvl.size() > 0) + { + for (std::size_t i = 0; i < n_itv; i++) + { + auto res = xt::where(xt::equal(xt::view(quantiles, i), q_lvl)); + if (res.size() != 2) + { + throw std::runtime_error( + "interval-based metric requested, " + "but *c_lvl* not matching *q_lvl" + ); + } else + { + xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = + xt::view(q_prd, res[0]); + xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = + xt::view(q_prd, res[1]); + } + } + } + else { + for (std::size_t i = 0; i < n_itv; i++) + { auto q = xt::quantile(q_prd, xt::view(quantiles, i), 2); xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = xt::view(q, 0); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = xt::view(q, 1); + } } return itv_bnds; diff --git a/include/evalhyd/detail/probabilist/quantiles.hpp b/include/evalhyd/detail/probabilist/quantiles.hpp index 88bd528..bb13751 100644 --- a/include/evalhyd/detail/probabilist/quantiles.hpp +++ b/include/evalhyd/detail/probabilist/quantiles.hpp @@ -60,13 +60,22 @@ namespace evalhyd inline xt::xtensor<double, 4> calc_qs( const XD2 &q_obs, const xt::xtensor<double, 4>& q_qnt, - std::size_t n_mbr + std::size_t n_mbr, + const xt::xtensor<double, 1>& q_lvl ) { - // compute the quantile order $alpha$ - xt::xtensor<double, 1> alpha = + xt::xtensor<double, 1> alpha; + // get or compute the quantile order $alpha$ + if (q_lvl.size() > 0) + { + alpha = xt::sort(q_lvl); + } + else + { + alpha = xt::arange<double>(1., double(n_mbr + 1)) / double(n_mbr + 1); + } // calculate the difference xt::xtensor<double, 4> diff = diff --git a/include/evalhyd/evalp.hpp b/include/evalhyd/evalp.hpp index f7f4340..0039677 100644 --- a/include/evalhyd/evalp.hpp +++ b/include/evalhyd/evalp.hpp @@ -181,6 +181,7 @@ namespace evalhyd xtl::xoptional<const std::string, bool> events = xtl::missing<const std::string>(), const std::vector<double>& c_lvl = {}, + const std::vector<double>& q_lvl = {}, const xt::xexpression<XB4>& t_msk = XB4({}), const xt::xexpression<XS2>& m_cdt = XS2({}), xtl::xoptional<const std::unordered_map<std::string, int>, bool> bootstrap = @@ -233,6 +234,7 @@ namespace evalhyd // adapt vector to tensor const xt::xtensor<double, 1> c_lvl_ = xt::adapt(c_lvl); + const xt::xtensor<double, 1> q_lvl_ = xt::adapt(q_lvl); // check that the metrics/diagnostics to be computed are valid utils::check_metrics( @@ -418,7 +420,7 @@ namespace evalhyd // instantiate determinist evaluator probabilist::Evaluator<XD2, XD4, XB4> evaluator( - q_obs_, q_prd_, q_thr_, c_lvl_, events, + q_obs_, q_prd_, q_thr_, c_lvl_, q_lvl_, events, t_msk_.size() > 0 ? t_msk_: (m_cdt_.size() > 0 ? c_msk : t_msk_), b_exp, random_seed -- GitLab From 61d1e3ac57f5d19f67e0b7a7ef5e4f8fba6ab8bc Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Tue, 8 Apr 2025 14:28:15 +0200 Subject: [PATCH 02/31] use broadcasting to find the q_lvl indices in q_prd --- include/evalhyd/detail/probabilist/intervals.hpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 21316f2..f5ed846 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -66,7 +66,9 @@ namespace evalhyd { for (std::size_t i = 0; i < n_itv; i++) { - auto res = xt::where(xt::equal(xt::view(quantiles, i), q_lvl)); + auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); + auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); + auto res = xt::where(xt::equal(a, xt::transpose(b)); if (res.size() != 2) { throw std::runtime_error( @@ -76,9 +78,9 @@ namespace evalhyd } else { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, res[0]); + xt::view(q_prd, std::min(res[0][1], res[1][1])); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, res[1]); + xt::view(q_prd, std::max(res[0][1], res[1][1])); } } } -- GitLab From d7abf7feada694376fd5d1dc2d6219cb8ca20ad7 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Tue, 8 Apr 2025 14:33:40 +0200 Subject: [PATCH 03/31] wip --- include/evalhyd/detail/probabilist/intervals.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index f5ed846..a663969 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -68,7 +68,7 @@ namespace evalhyd { auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); - auto res = xt::where(xt::equal(a, xt::transpose(b)); + auto res = xt::where(xt::equal(a, xt::transpose(b))); if (res.size() != 2) { throw std::runtime_error( -- GitLab From 5adc574d7b7990c397a0921f850ffdca2663b40f Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Tue, 8 Apr 2025 14:47:46 +0200 Subject: [PATCH 04/31] wip --- tests/test_probabilist.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index 87a0303..186ed72 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -246,6 +246,7 @@ TEST(ProbabilistTests, TestRanks) xt::xtensor<double, 2>({}), "high", // events {}, // c_lvl + {}, // q_lvl xt::xtensor<bool, 4>({}), // t_msk xt::xtensor<std::array<char, 32>, 2>({}), // m_cdt xtl::missing<const std::unordered_map<std::string, int>>(), // bootstrap @@ -361,6 +362,7 @@ TEST(ProbabilistTests, TestMasks) thresholds, "high", confidence_levels, + {}, // q_lvl // shape: (sites [1], lead times [1], subsets [1], time [t]) masks ); @@ -431,6 +433,7 @@ TEST(ProbabilistTests, TestMaskingConditions) thresholds, "high", confidence_levels, + {}, // q_lvl masks, q_conditions ); @@ -488,6 +491,7 @@ TEST(ProbabilistTests, TestMaskingConditions) thresholds, "high", confidence_levels, + {}, // q_lvl masks, q_conditions_ ); @@ -542,6 +546,7 @@ TEST(ProbabilistTests, TestMaskingConditions) thresholds, "high", confidence_levels, + {}, // q_lvl masks, t_conditions ); @@ -705,6 +710,7 @@ TEST(ProbabilistTests, TestBootstrap) thresholds, "high", // events confidence_levels, + {}, // q_lvl xt::xtensor<bool, 4>({}), // t_msk xt::xtensor<std::array<char, 32>, 2>({}), // m_cdt bootstrap, @@ -790,6 +796,7 @@ TEST(ProbabilistTests, TestBootstrapSummary) thresholds, "high", // events confidence_levels, + {}, // q_lvl xt::xtensor<bool, 4>({}), // t_msk xt::xtensor<std::array<char, 32>, 2>({}), // m_cdt bootstrap_0, @@ -808,6 +815,7 @@ TEST(ProbabilistTests, TestBootstrapSummary) thresholds, "high", // events confidence_levels, + {}, // q_lvl xt::xtensor<bool, 4>({}), // t_msk xt::xtensor<std::array<char, 32>, 2>({}), // m_cdt bootstrap_1, @@ -859,6 +867,7 @@ TEST(ProbabilistTests, TestBootstrapSummary) thresholds, "high", // events confidence_levels, + {}, // q_lvl xt::xtensor<bool, 4>({}), // t_msk xt::xtensor<std::array<char, 32>, 2>({}), // m_cdt bootstrap_2, @@ -935,6 +944,7 @@ TEST(ProbabilistTests, TestCompleteness) xt::xtensor<double, 2>({}), // thresholds xtl::missing<const std::string>(), // events {}, + {}, // q_lvl msk, // t_msk xt::xtensor<std::array<char, 32>, 2>({}), // m_cdt xtl::missing<const std::unordered_map<std::string, int>>(), // bootstrap -- GitLab From 08900c91aee602e4653d3638254559960ef32ba0 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Tue, 22 Apr 2025 15:45:01 +0200 Subject: [PATCH 05/31] wip - add a test --- tests/test_probabilist.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index 186ed72..0ee579f 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -297,6 +297,41 @@ TEST(ProbabilistTests, TestIntervals) } } +TEST(ProbabilistTests, TestIntervalsQLVL) +{ + // read in data + xt::xtensor<double, 1> observed; + xt::xtensor<double, 2> predicted; + std::tie(observed, predicted) = load_data_p(); + + // read in expected results + auto expected = load_expected_p(); + + // compute scores + std::vector<std::string> metrics = {"CR"}; + + std::vector<xt::xarray<double>> results = + evalhyd::evalp( + // shape: (sites [1], time [t]) + xt::eval(xt::view(observed, xt::newaxis(), xt::all())), + // shape: (sites [1], lead times [1], members [m], time [t]) + xt::eval(xt::view(predicted, xt::newaxis(), xt::newaxis(), xt::range(0, 4), xt::all())), + metrics, + xt::xtensor<double, 2>({}), + "", // events + {50., 80.}, // c_lvl + {0.1, 0.25, 0.75, 0.9} // q_lvl + ); + + // check results + for (std::size_t m = 0; m < metrics.size(); m++) + { + EXPECT_TRUE(xt::all(xt::isclose( + results[m], expected[metrics[m]], 1e-05, 1e-08, true + ))) << "Failure for (" << metrics[m] << ")"; + } +} + TEST(ProbabilistTests, TestMultiVariate) { // read in data -- GitLab From 17baf6f9f3cb2279840275ed4a441600fbc02461 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Tue, 22 Apr 2025 16:54:29 +0200 Subject: [PATCH 06/31] pin xtensor --- environment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment.yml b/environment.yml index deaaf24..b1f5e68 100644 --- a/environment.yml +++ b/environment.yml @@ -8,7 +8,7 @@ dependencies: - make # Host dependencies - xtl - - xtensor + - xtensor=0.25 # Test dependencies - gtest - gmock -- GitLab From d1b87524b3644e20294303945a1c656e6dab0fd6 Mon Sep 17 00:00:00 2001 From: Thibault Hallouin <thibault.hallouin@inrae.fr> Date: Tue, 22 Apr 2025 20:14:46 +0200 Subject: [PATCH 07/31] add trivial getter method for q_lvl to be consistent with other ones --- include/evalhyd/detail/probabilist/evaluator.hpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/evaluator.hpp b/include/evalhyd/detail/probabilist/evaluator.hpp index 619104e..c01c54b 100644 --- a/include/evalhyd/detail/probabilist/evaluator.hpp +++ b/include/evalhyd/detail/probabilist/evaluator.hpp @@ -158,6 +158,11 @@ namespace evalhyd } } + auto get_q_lvl() + { + return _q_lvl; + } + bool is_high_flow_event() { if (_events.has_value()) @@ -337,7 +342,7 @@ namespace evalhyd if (!itv_bnds.has_value()) { itv_bnds = elements::calc_itv_bnds( - q_prd, get_c_lvl(), _q_lvl, + q_prd, get_c_lvl(), get_q_lvl(), n_sit, n_ldt, n_itv, n_tim ); } @@ -394,7 +399,7 @@ namespace evalhyd if (!qs.has_value()) { qs = intermediate::calc_qs( - q_obs, get_q_qnt(), n_mbr, _q_lvl + q_obs, get_q_qnt(), n_mbr, get_q_lvl() ); } return qs.value(); -- GitLab From 14bcf4ae10ace38ebb2f9b5410dbead1eede097c Mon Sep 17 00:00:00 2001 From: Thibault Hallouin <thibault.hallouin@inrae.fr> Date: Tue, 22 Apr 2025 20:15:44 +0200 Subject: [PATCH 08/31] improve dealing with situation where q_lvl provided in place of c_lvl --- include/evalhyd/detail/probabilist/evaluator.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/evalhyd/detail/probabilist/evaluator.hpp b/include/evalhyd/detail/probabilist/evaluator.hpp index c01c54b..76f8de0 100644 --- a/include/evalhyd/detail/probabilist/evaluator.hpp +++ b/include/evalhyd/detail/probabilist/evaluator.hpp @@ -146,11 +146,11 @@ namespace evalhyd auto get_c_lvl() { - if (_c_lvl.size() < 1) + if (_c_lvl.size() < 1 && _q_lvl.size() < 1) { throw std::runtime_error( "interval-based metric requested, " - "but *c_lvl* not provided" + "but neither *c_lvl* nor *q_lvl* provided" ); } else{ @@ -515,7 +515,7 @@ namespace evalhyd n_tim = q_prd.shape(3); n_msk = t_msk.shape(2); n_thr = _q_thr.shape(1); - n_itv = _c_lvl.size(); + n_itv = _q_lvl.size() > 0 ? _q_lvl.size() : _c_lvl.size(); n_exp = b_exp.size(); // drop time steps where observations and/or predictions are NaN -- GitLab From 861dbee8f4664720416203de668f12b7b00f0bd3 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:19:15 +0200 Subject: [PATCH 09/31] Revert "improve dealing with situation where q_lvl provided in place of c_lvl" This reverts commit 14bcf4ae10ace38ebb2f9b5410dbead1eede097c. --- include/evalhyd/detail/probabilist/evaluator.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/evalhyd/detail/probabilist/evaluator.hpp b/include/evalhyd/detail/probabilist/evaluator.hpp index 76f8de0..c01c54b 100644 --- a/include/evalhyd/detail/probabilist/evaluator.hpp +++ b/include/evalhyd/detail/probabilist/evaluator.hpp @@ -146,11 +146,11 @@ namespace evalhyd auto get_c_lvl() { - if (_c_lvl.size() < 1 && _q_lvl.size() < 1) + if (_c_lvl.size() < 1) { throw std::runtime_error( "interval-based metric requested, " - "but neither *c_lvl* nor *q_lvl* provided" + "but *c_lvl* not provided" ); } else{ @@ -515,7 +515,7 @@ namespace evalhyd n_tim = q_prd.shape(3); n_msk = t_msk.shape(2); n_thr = _q_thr.shape(1); - n_itv = _q_lvl.size() > 0 ? _q_lvl.size() : _c_lvl.size(); + n_itv = _c_lvl.size(); n_exp = b_exp.size(); // drop time steps where observations and/or predictions are NaN -- GitLab From ec42e5d8816e2b3c196d08b38b787aa60b7bbc2b Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:21:13 +0200 Subject: [PATCH 10/31] wip - test --- tests/test_probabilist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index 0ee579f..4cea2a8 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -320,7 +320,7 @@ TEST(ProbabilistTests, TestIntervalsQLVL) xt::xtensor<double, 2>({}), "", // events {50., 80.}, // c_lvl - {0.1, 0.25, 0.75, 0.9} // q_lvl + {10., 25., 75., 90.} // q_lvl ); // check results -- GitLab From c60101b65773174ed9e01e9543b68005e474e2bd Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:32:16 +0200 Subject: [PATCH 11/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index a663969..340337a 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -78,9 +78,9 @@ namespace evalhyd } else { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, std::min(res[0][1], res[1][1])); + xt::view(q_prd, 0); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, std::max(res[0][1], res[1][1])); + xt::view(q_prd, 1); } } } -- GitLab From 1a7a57a03d95a888bed6300ac3dcdd2b75e03f57 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:40:19 +0200 Subject: [PATCH 12/31] wip - debug --- .../evalhyd/detail/probabilist/intervals.hpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 340337a..d1d1d53 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -67,21 +67,21 @@ namespace evalhyd for (std::size_t i = 0; i < n_itv; i++) { auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); - auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); - auto res = xt::where(xt::equal(a, xt::transpose(b))); - if (res.size() != 2) - { - throw std::runtime_error( - "interval-based metric requested, " - "but *c_lvl* not matching *q_lvl" - ); - } else - { + //auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); + //auto res = xt::where(xt::equal(a, xt::transpose(b))); + //if (res.size() != 2) + //{ + // throw std::runtime_error( + // "interval-based metric requested, " + // "but *c_lvl* not matching *q_lvl" + // ); + //} else + //{ xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = xt::view(q_prd, 0); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = xt::view(q_prd, 1); - } + //} } } else -- GitLab From 0a4a524711787beac9f5d6aa73b9f9d2cc400f61 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:45:54 +0200 Subject: [PATCH 13/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index d1d1d53..990eac2 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -66,7 +66,7 @@ namespace evalhyd { for (std::size_t i = 0; i < n_itv; i++) { - auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); + //auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); //auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); //auto res = xt::where(xt::equal(a, xt::transpose(b))); //if (res.size() != 2) -- GitLab From 41d092487335867b8ea50a35ae404b803ff68652 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:56:27 +0200 Subject: [PATCH 14/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 990eac2..b06ff3d 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -78,9 +78,9 @@ namespace evalhyd //} else //{ xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, 0); + xt::view(q_prd, xt::all(), xt::all(), 0, xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, 1); + xt::view(q_prd, xt::all(), xt::all(), 1, xt::all())); //} } } -- GitLab From f1e032bfdf68d17e1c4a4facf4d99cb93ff4bda1 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 09:59:37 +0200 Subject: [PATCH 15/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index b06ff3d..0f76ec0 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -80,7 +80,7 @@ namespace evalhyd xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = xt::view(q_prd, xt::all(), xt::all(), 0, xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), 1, xt::all())); + xt::view(q_prd, xt::all(), xt::all(), 1, xt::all()); //} } } -- GitLab From 2388f65ee57453bd2ae760d77ea9efee2c741a4d Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 11:53:09 +0200 Subject: [PATCH 16/31] wip - debug --- .../evalhyd/detail/probabilist/intervals.hpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 0f76ec0..1c91aea 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -66,22 +66,22 @@ namespace evalhyd { for (std::size_t i = 0; i < n_itv; i++) { - //auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); - //auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); - //auto res = xt::where(xt::equal(a, xt::transpose(b))); - //if (res.size() != 2) - //{ - // throw std::runtime_error( - // "interval-based metric requested, " - // "but *c_lvl* not matching *q_lvl" - // ); - //} else - //{ + auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); + auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); + auto res = xt::where(xt::equal(a, xt::transpose(b))); + if (res.size() != 2) + { + throw std::runtime_error( + "interval-based metric requested, " + "but *c_lvl* not matching *q_lvl" + ); + } else + { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), 0, xt::all()); + xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][1], res[1][1], xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), 1, xt::all()); - //} + xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][1], res[1][1], xt::all()); + } } } else -- GitLab From 114991b7b20b0711646ff1aedbfa7642f0cbc408 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 11:57:16 +0200 Subject: [PATCH 17/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 1c91aea..59d76d6 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -78,9 +78,9 @@ namespace evalhyd } else { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][1], res[1][1], xt::all()); + xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][1], res[1][1], xt::all())); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][1], res[1][1], xt::all()); + xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][1], res[1][1], xt::all())); } } } -- GitLab From cda19fae67797dcb3ed3e05611fd8978121fc20a Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 12:05:46 +0200 Subject: [PATCH 18/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 59d76d6..4ed6a92 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -78,9 +78,9 @@ namespace evalhyd } else { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][1], res[1][1], xt::all())); + xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][1], res[1][1]), xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][1], res[1][1], xt::all())); + xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][1], res[1][1]), xt::all()); } } } -- GitLab From 7ce3a956cac674366cdebaf450d237e9fee2c9cf Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 12:12:38 +0200 Subject: [PATCH 19/31] wip - debug --- .../evalhyd/detail/probabilist/intervals.hpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 4ed6a92..19577cf 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -69,19 +69,19 @@ namespace evalhyd auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); - if (res.size() != 2) - { - throw std::runtime_error( - "interval-based metric requested, " - "but *c_lvl* not matching *q_lvl" - ); - } else - { + //if (res.size() != 2) + //{ + // throw std::runtime_error( + // "interval-based metric requested, " + // "but *c_lvl* not matching *q_lvl" + // ); + //} else + //{ xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][1], res[1][1]), xt::all()); + xt::view(q_prd, xt::all(), xt::all(), 0, xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][1], res[1][1]), xt::all()); - } + xt::view(q_prd, xt::all(), xt::all(), 1, xt::all()); + //} } } else -- GitLab From fa36d5c033162efa3e46caf54a9e072cbc5f3f6f Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 13:04:35 +0200 Subject: [PATCH 20/31] wip - debug --- .../evalhyd/detail/probabilist/intervals.hpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 19577cf..1033e5c 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -69,19 +69,20 @@ namespace evalhyd auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); - //if (res.size() != 2) - //{ - // throw std::runtime_error( - // "interval-based metric requested, " - // "but *c_lvl* not matching *q_lvl" - // ); - //} else - //{ + std::cout << "res: " << res << std::endl; + if (res.size() != 2) + { + throw std::runtime_error( + "interval-based metric requested, " + "but *c_lvl* not matching *q_lvl" + ); + } else + { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = xt::view(q_prd, xt::all(), xt::all(), 0, xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = xt::view(q_prd, xt::all(), xt::all(), 1, xt::all()); - //} + } } } else -- GitLab From 8baaa2f56276a9662178868720f235a14dcf548b Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 13:13:25 +0200 Subject: [PATCH 21/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 1033e5c..51ab71e 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -69,7 +69,9 @@ namespace evalhyd auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); - std::cout << "res: " << res << std::endl; + std::cout << "res: " << res.size() << std::endl; + std::cout << "res: " << res[0][1] << std::endl; + std::cout << "res: " << res[1][1] << std::endl; if (res.size() != 2) { throw std::runtime_error( -- GitLab From b56ac2a6ddcafbcd820e3062ca6b36492d1f93cc Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 13:25:35 +0200 Subject: [PATCH 22/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 51ab71e..2052631 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -67,11 +67,11 @@ namespace evalhyd for (std::size_t i = 0; i < n_itv; i++) { auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); - auto b = xt::broadcast(q_lvl, std::vector<std::size_t>({2, q_lvl.size()})); + auto b = xt::broadcast(q_lvl / 100., std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); std::cout << "res: " << res.size() << std::endl; - std::cout << "res: " << res[0][1] << std::endl; - std::cout << "res: " << res[1][1] << std::endl; + std::cout << "res: " << res[0] << std::endl; + std::cout << "res: " << res[1] << std::endl; if (res.size() != 2) { throw std::runtime_error( -- GitLab From e5c8d50d476f16e2cd69d1d50d4f8ff871d5b34f Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 13:44:40 +0200 Subject: [PATCH 23/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 2052631..f0d2314 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -70,8 +70,8 @@ namespace evalhyd auto b = xt::broadcast(q_lvl / 100., std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); std::cout << "res: " << res.size() << std::endl; - std::cout << "res: " << res[0] << std::endl; - std::cout << "res: " << res[1] << std::endl; + std::cout << "res: " << res[0][0] << std::endl; + std::cout << "res: " << res[1][0] << std::endl; if (res.size() != 2) { throw std::runtime_error( -- GitLab From 58cc6d9f14831c886c5fe22afffe8b60206034f0 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 13:54:08 +0200 Subject: [PATCH 24/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index f0d2314..b1dc910 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -70,8 +70,8 @@ namespace evalhyd auto b = xt::broadcast(q_lvl / 100., std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); std::cout << "res: " << res.size() << std::endl; - std::cout << "res: " << res[0][0] << std::endl; - std::cout << "res: " << res[1][0] << std::endl; + std::cout << "res_0: " << res[0][0] << std::endl; + std::cout << "res_1: " << res[1][0] << std::endl; if (res.size() != 2) { throw std::runtime_error( -- GitLab From 1b15cac81ba83bc949df5c7e8dfcaffee16b41c8 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 14:08:56 +0200 Subject: [PATCH 25/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index b1dc910..e0dcd25 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -70,8 +70,10 @@ namespace evalhyd auto b = xt::broadcast(q_lvl / 100., std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); std::cout << "res: " << res.size() << std::endl; - std::cout << "res_0: " << res[0][0] << std::endl; - std::cout << "res_1: " << res[1][0] << std::endl; + std::cout << "res_00: " << res[0][0] << std::endl; + std::cout << "res_01: " << res[0][1] << std::endl; + std::cout << "res_10: " << res[1][0] << std::endl; + std::cout << "res_11: " << res[1][1] << std::endl; if (res.size() != 2) { throw std::runtime_error( -- GitLab From 93328af6a668031e77279bf336e03c9575f65640 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 14:39:16 +0200 Subject: [PATCH 26/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index e0dcd25..4e4d29a 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -69,11 +69,16 @@ namespace evalhyd auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); auto b = xt::broadcast(q_lvl / 100., std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); + std::cout << "res: " << res.size() << std::endl; std::cout << "res_00: " << res[0][0] << std::endl; std::cout << "res_01: " << res[0][1] << std::endl; std::cout << "res_10: " << res[1][0] << std::endl; std::cout << "res_11: " << res[1][1] << std::endl; + + std::cout << "res_min: " << std::min(res[0][0], res[0][1]) << std::endl; + std::cout << "res_max: " << std::max(res[0][0], res[0][1]) << std::endl; + if (res.size() != 2) { throw std::runtime_error( -- GitLab From 6efc5a889b551aa29acd81708009c30bd63b531b Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 14:47:48 +0200 Subject: [PATCH 27/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 4e4d29a..3bfe578 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -88,9 +88,9 @@ namespace evalhyd } else { xt::view(itv_bnds, xt::all(), xt::all(), i, 0, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), 0, xt::all()); + xt::view(q_prd, xt::all(), xt::all(), std::min(res[0][0], res[0][1]), xt::all()); xt::view(itv_bnds, xt::all(), xt::all(), i, 1, xt::all()) = - xt::view(q_prd, xt::all(), xt::all(), 1, xt::all()); + xt::view(q_prd, xt::all(), xt::all(), std::max(res[0][0], res[0][1]), xt::all()); } } } -- GitLab From f54267350d16beecbd2571f514c0b9065a7921bc Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 15:00:53 +0200 Subject: [PATCH 28/31] wip - debug --- include/evalhyd/detail/probabilist/intervals.hpp | 9 --------- tests/expected/evalp/CR_QLVL.csv | 1 + tests/test_probabilist.cpp | 8 +++++--- 3 files changed, 6 insertions(+), 12 deletions(-) create mode 100644 tests/expected/evalp/CR_QLVL.csv diff --git a/include/evalhyd/detail/probabilist/intervals.hpp b/include/evalhyd/detail/probabilist/intervals.hpp index 3bfe578..f52fd5a 100644 --- a/include/evalhyd/detail/probabilist/intervals.hpp +++ b/include/evalhyd/detail/probabilist/intervals.hpp @@ -69,15 +69,6 @@ namespace evalhyd auto a = xt::broadcast(xt::view(quantiles, i), std::vector<std::size_t>({q_lvl.size(), 2})); auto b = xt::broadcast(q_lvl / 100., std::vector<std::size_t>({2, q_lvl.size()})); auto res = xt::where(xt::equal(a, xt::transpose(b))); - - std::cout << "res: " << res.size() << std::endl; - std::cout << "res_00: " << res[0][0] << std::endl; - std::cout << "res_01: " << res[0][1] << std::endl; - std::cout << "res_10: " << res[1][0] << std::endl; - std::cout << "res_11: " << res[1][1] << std::endl; - - std::cout << "res_min: " << std::min(res[0][0], res[0][1]) << std::endl; - std::cout << "res_max: " << std::max(res[0][0], res[0][1]) << std::endl; if (res.size() != 2) { diff --git a/tests/expected/evalp/CR_QLVL.csv b/tests/expected/evalp/CR_QLVL.csv new file mode 100644 index 0000000..a4a7469 --- /dev/null +++ b/tests/expected/evalp/CR_QLVL.csv @@ -0,0 +1 @@ +0.0064308681672,0.0353697749196 diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index 4cea2a8..efe0ba1 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -36,7 +36,8 @@ std::vector<std::string> all_metrics_p = { "CONT_TBL", "POD", "POFD", "FAR", "CSI", "ROCSS", "RANK_HIST", "DS", "AS", "CR", "AW", "AWN", "WS", - "ES" + "ES", + "CR_QLVL" }; std::tuple<xt::xtensor<double, 1>, xt::xtensor<double, 2>> load_data_p() @@ -309,13 +310,14 @@ TEST(ProbabilistTests, TestIntervalsQLVL) // compute scores std::vector<std::string> metrics = {"CR"}; + std::vector<std::string> metrics_ = {"CR_QLVL"}; std::vector<xt::xarray<double>> results = evalhyd::evalp( // shape: (sites [1], time [t]) xt::eval(xt::view(observed, xt::newaxis(), xt::all())), // shape: (sites [1], lead times [1], members [m], time [t]) - xt::eval(xt::view(predicted, xt::newaxis(), xt::newaxis(), xt::range(0, 4), xt::all())), + xt::eval(xt::view(predicted, xt::newaxis(), xt::newaxis(), xt::keep(0, 15, 30, 50), xt::all())), metrics, xt::xtensor<double, 2>({}), "", // events @@ -327,7 +329,7 @@ TEST(ProbabilistTests, TestIntervalsQLVL) for (std::size_t m = 0; m < metrics.size(); m++) { EXPECT_TRUE(xt::all(xt::isclose( - results[m], expected[metrics[m]], 1e-05, 1e-08, true + results[m], expected[metrics_[m]], 1e-05, 1e-08, true ))) << "Failure for (" << metrics[m] << ")"; } } -- GitLab From 0f080d225726951b48cf1f50eb7de747b6a6512f Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 15:14:54 +0200 Subject: [PATCH 29/31] wip - debug --- tests/test_probabilist.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index efe0ba1..a4bd6b0 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -30,6 +30,16 @@ using namespace xt::placeholders; // required for `_` to work std::vector<std::string> all_metrics_p = { + "BS", "BSS", "BS_CRD", "BS_LBD", "REL_DIAG", "CRPS_FROM_BS", + "CRPS_FROM_ECDF", + "QS", "CRPS_FROM_QS", + "CONT_TBL", "POD", "POFD", "FAR", "CSI", "ROCSS", + "RANK_HIST", "DS", "AS", + "CR", "AW", "AWN", "WS", + "ES" +}; + +std::vector<std::string> all_metrics_p_ = { "BS", "BSS", "BS_CRD", "BS_LBD", "REL_DIAG", "CRPS_FROM_BS", "CRPS_FROM_ECDF", "QS", "CRPS_FROM_QS", @@ -61,7 +71,7 @@ std::unordered_map<std::string, xt::xarray<double>> load_expected_p() std::ifstream ifs; std::unordered_map<std::string, xt::xarray<double>> expected; - for (const auto& metric : all_metrics_p) + for (const auto& metric : all_metrics_p_) { ifs.open(EVALHYD_DATA_DIR "/expected/evalp/" + metric + ".csv"); expected[metric] = xt::view( -- GitLab From c877f461f6e1773c6ae4260fe75be7e11b56e5e6 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 15:28:07 +0200 Subject: [PATCH 30/31] wip - debug --- tests/test_probabilist.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index a4bd6b0..4c8bc28 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -338,6 +338,9 @@ TEST(ProbabilistTests, TestIntervalsQLVL) // check results for (std::size_t m = 0; m < metrics.size(); m++) { + std::cout << results[m][0] << std::endl; + std::cout << results[m][1] << std::endl; + EXPECT_TRUE(xt::all(xt::isclose( results[m], expected[metrics_[m]], 1e-05, 1e-08, true ))) << "Failure for (" << metrics[m] << ")"; -- GitLab From 4c7d7cee97041a5966e19ea1daa9abf82d3d5ff0 Mon Sep 17 00:00:00 2001 From: fbourgin <francois.bourgin@inrae.fr> Date: Thu, 24 Apr 2025 15:35:20 +0200 Subject: [PATCH 31/31] wip - debug --- tests/expected/evalp/CR_QLVL.csv | 2 +- tests/test_probabilist.cpp | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/expected/evalp/CR_QLVL.csv b/tests/expected/evalp/CR_QLVL.csv index a4a7469..dfefd7e 100644 --- a/tests/expected/evalp/CR_QLVL.csv +++ b/tests/expected/evalp/CR_QLVL.csv @@ -1 +1 @@ -0.0064308681672,0.0353697749196 +0.00643087,0.0514469 diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index 4c8bc28..a4bd6b0 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -338,9 +338,6 @@ TEST(ProbabilistTests, TestIntervalsQLVL) // check results for (std::size_t m = 0; m < metrics.size(); m++) { - std::cout << results[m][0] << std::endl; - std::cout << results[m][1] << std::endl; - EXPECT_TRUE(xt::all(xt::isclose( results[m], expected[metrics_[m]], 1e-05, 1e-08, true ))) << "Failure for (" << metrics[m] << ")"; -- GitLab