From 740569122d1be938b6ec944e4866cd7d5e073010 Mon Sep 17 00:00:00 2001 From: Thibault Hallouin <thibault.hallouin@inrae.fr> Date: Thu, 25 Aug 2022 16:12:13 +0200 Subject: [PATCH] isolate evalp-specific utils in their own namespace --- include/evalhyd/evalp.hpp | 2 +- src/utils.hpp | 47 +++++++++++++++++++++------------------ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/include/evalhyd/evalp.hpp b/include/evalhyd/evalp.hpp index ce9d8e0..3263d26 100644 --- a/include/evalhyd/evalp.hpp +++ b/include/evalhyd/evalp.hpp @@ -100,7 +100,7 @@ namespace evalhyd ); // check that optional parameters are given as arguments - eh::utils::check_optionals(metrics, q_thr); + eh::utils::evalp::check_optionals(metrics, q_thr); // check that data dimensions are compatible // > time diff --git a/src/utils.hpp b/src/utils.hpp index 8637639..5efbcee 100644 --- a/src/utils.hpp +++ b/src/utils.hpp @@ -92,30 +92,33 @@ namespace evalhyd } } - /// Procedure to check that optional parameters are provided - /// as arguments when required metrics need them. - /// - /// \param [in] metrics: - /// Vector of strings for the metric(s) to be computed. - /// \param [in] thresholds: - /// Array of thresholds for metrics based on exceedance events. - inline void check_optionals ( - const std::vector<std::string>& metrics, - const xt::xtensor<double, 1>& thresholds - ) + namespace evalp { - std::vector<std::string>threshold_metrics = - {"BS", "BS_CRD", "BS_LBD", "BSS"}; - - for (const auto& metric : metrics) + /// Procedure to check that optional parameters are provided + /// as arguments when required metrics need them. + /// + /// \param [in] metrics: + /// Vector of strings for the metric(s) to be computed. + /// \param [in] thresholds: + /// Array of thresholds for metrics based on exceedance events. + inline void check_optionals ( + const std::vector<std::string>& metrics, + const xt::xtensor<double, 1>& thresholds + ) { - if (std::find(threshold_metrics.begin(), threshold_metrics.end(), - metric) != threshold_metrics.end()) - if (thresholds.size() < 1) - throw std::runtime_error( - "missing thresholds *q_thr* required to " - "compute " + metric - ); + std::vector<std::string>threshold_metrics = + {"BS", "BS_CRD", "BS_LBD", "BSS"}; + + for (const auto& metric : metrics) + { + if (std::find(threshold_metrics.begin(), threshold_metrics.end(), + metric) != threshold_metrics.end()) + if (thresholds.size() < 1) + throw std::runtime_error( + "missing thresholds *q_thr* required to " + "compute " + metric + ); + } } } } -- GitLab