From 709745a62fe4b7070e6b63a13d1e35f3b8a6beb9 Mon Sep 17 00:00:00 2001 From: Thibault Hallouin <thibault.hallouin@inrae.fr> Date: Thu, 2 Jun 2022 16:58:30 +0200 Subject: [PATCH] reorder positional parameters so that metrics are last This is because in the CLI, metrics is a sequence of unknown length, so it was only possible to make it last positional parameters. In order to keep the interfaces harmonised across Python/R/C++ APIs and the CLI, metrics needed to be put last positional parameter. --- include/evalhyd/determinist.hpp | 8 ++++---- include/evalhyd/probabilist.hpp | 6 +++--- tests/test_determinist.cpp | 4 ++-- tests/test_probabilist.cpp | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/include/evalhyd/determinist.hpp b/include/evalhyd/determinist.hpp index 8a716a9..6b4bc9f 100644 --- a/include/evalhyd/determinist.hpp +++ b/include/evalhyd/determinist.hpp @@ -15,21 +15,21 @@ namespace evalhyd /// Function allowing the evaluation of streamflow simulations using a /// range of relevant metrics. /// - /// \param [in] metrics: - /// Vector of strings for the metric(s) to be computed. /// \param [in] q_obs: /// 2D array of streamflow observations. /// shape: (1+, time) /// \param [in] q_sim: /// 2D array of streamflow simulations. /// shape: (1+, time) + /// \param [in] metrics: + /// Vector of strings for the metric(s) to be computed. /// \return /// Vector of 1D array of metrics for each time series. template <class A> std::vector<A> evald( - const std::vector<std::string>& metrics, const xt::xexpression<A>& q_obs, - const xt::xexpression<A>& q_sim + const xt::xexpression<A>& q_sim, + const std::vector<std::string>& metrics ) { const A& obs = q_obs.derived_cast(); diff --git a/include/evalhyd/probabilist.hpp b/include/evalhyd/probabilist.hpp index d05cf99..8bf5e19 100644 --- a/include/evalhyd/probabilist.hpp +++ b/include/evalhyd/probabilist.hpp @@ -17,23 +17,23 @@ namespace evalhyd /// Function allowing the evaluation of streamflow forecasts using a /// range of relevant metrics. /// - /// \param [in] metrics: - /// Vector of strings for the metric(s) to be computed. /// \param [in] q_obs: /// 2D array of streamflow observations. /// shape: (1, time) /// \param [in] q_frc: /// 2D array of streamflow forecasts. /// shape: (members, time) + /// \param [in] metrics: + /// Vector of strings for the metric(s) to be computed. /// \param [in] q_thr (optional): /// 1D array of streamflow exceedance threshold(s). /// shape: (thresholds,) /// \return /// Vector of 2D array of metrics for each threshold. std::vector<xt::xtensor<double, 2>> evalp( - const std::vector<std::string>& metrics, const xt::xtensor<double, 2>& q_obs, const xt::xtensor<double, 2>& q_frc, + const std::vector<std::string>& metrics, const xt::xtensor<double, 1>& q_thr = {} ) { diff --git a/tests/test_determinist.cpp b/tests/test_determinist.cpp index 0d8fe65..50aca43 100644 --- a/tests/test_determinist.cpp +++ b/tests/test_determinist.cpp @@ -29,12 +29,12 @@ TEST(DeterministTests, TestNSE) { // compute scores (both with 2D and 1D tensors) std::vector<xt::xtensor<double, 2>> metrics_2d = evalhyd::evald<xt::xtensor<double, 2>>( - {"NSE"}, observed_2d, forecast_2d + observed_2d, forecast_2d, {"NSE"} ); std::vector<xt::xtensor<double, 1>> metrics_1d = evalhyd::evald<xt::xtensor<double, 1>>( - {"NSE"}, observed_1d, forecast_1d + observed_1d, forecast_1d, {"NSE"} ); // check results (both with 2D and 1D tensors) diff --git a/tests/test_probabilist.cpp b/tests/test_probabilist.cpp index 911c653..49c7a74 100644 --- a/tests/test_probabilist.cpp +++ b/tests/test_probabilist.cpp @@ -24,8 +24,8 @@ TEST(ProbabilistTests, TestBrier) { std::vector<xt::xtensor<double, 2>> metrics = evalhyd::evalp( - {"BS", "BSS", "BS_CRD", "BS_LBD"}, xt::transpose(observed), xt::transpose(forecast), + {"BS", "BSS", "BS_CRD", "BS_LBD"}, thresholds ); -- GitLab