Commit 709745a6 authored by Thibault Hallouin's avatar Thibault Hallouin
Browse files

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.
Showing with 10 additions and 10 deletions
+10 -10
...@@ -15,21 +15,21 @@ namespace evalhyd ...@@ -15,21 +15,21 @@ namespace evalhyd
/// Function allowing the evaluation of streamflow simulations using a /// Function allowing the evaluation of streamflow simulations using a
/// range of relevant metrics. /// range of relevant metrics.
/// ///
/// \param [in] metrics:
/// Vector of strings for the metric(s) to be computed.
/// \param [in] q_obs: /// \param [in] q_obs:
/// 2D array of streamflow observations. /// 2D array of streamflow observations.
/// shape: (1+, time) /// shape: (1+, time)
/// \param [in] q_sim: /// \param [in] q_sim:
/// 2D array of streamflow simulations. /// 2D array of streamflow simulations.
/// shape: (1+, time) /// shape: (1+, time)
/// \param [in] metrics:
/// Vector of strings for the metric(s) to be computed.
/// \return /// \return
/// Vector of 1D array of metrics for each time series. /// Vector of 1D array of metrics for each time series.
template <class A> template <class A>
std::vector<A> evald( std::vector<A> evald(
const std::vector<std::string>& metrics,
const xt::xexpression<A>& q_obs, 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(); const A& obs = q_obs.derived_cast();
......
...@@ -17,23 +17,23 @@ namespace evalhyd ...@@ -17,23 +17,23 @@ namespace evalhyd
/// Function allowing the evaluation of streamflow forecasts using a /// Function allowing the evaluation of streamflow forecasts using a
/// range of relevant metrics. /// range of relevant metrics.
/// ///
/// \param [in] metrics:
/// Vector of strings for the metric(s) to be computed.
/// \param [in] q_obs: /// \param [in] q_obs:
/// 2D array of streamflow observations. /// 2D array of streamflow observations.
/// shape: (1, time) /// shape: (1, time)
/// \param [in] q_frc: /// \param [in] q_frc:
/// 2D array of streamflow forecasts. /// 2D array of streamflow forecasts.
/// shape: (members, time) /// shape: (members, time)
/// \param [in] metrics:
/// Vector of strings for the metric(s) to be computed.
/// \param [in] q_thr (optional): /// \param [in] q_thr (optional):
/// 1D array of streamflow exceedance threshold(s). /// 1D array of streamflow exceedance threshold(s).
/// shape: (thresholds,) /// shape: (thresholds,)
/// \return /// \return
/// Vector of 2D array of metrics for each threshold. /// Vector of 2D array of metrics for each threshold.
std::vector<xt::xtensor<double, 2>> evalp( 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_obs,
const xt::xtensor<double, 2>& q_frc, const xt::xtensor<double, 2>& q_frc,
const std::vector<std::string>& metrics,
const xt::xtensor<double, 1>& q_thr = {} const xt::xtensor<double, 1>& q_thr = {}
) )
{ {
......
...@@ -29,12 +29,12 @@ TEST(DeterministTests, TestNSE) { ...@@ -29,12 +29,12 @@ TEST(DeterministTests, TestNSE) {
// compute scores (both with 2D and 1D tensors) // compute scores (both with 2D and 1D tensors)
std::vector<xt::xtensor<double, 2>> metrics_2d = std::vector<xt::xtensor<double, 2>> metrics_2d =
evalhyd::evald<xt::xtensor<double, 2>>( evalhyd::evald<xt::xtensor<double, 2>>(
{"NSE"}, observed_2d, forecast_2d observed_2d, forecast_2d, {"NSE"}
); );
std::vector<xt::xtensor<double, 1>> metrics_1d = std::vector<xt::xtensor<double, 1>> metrics_1d =
evalhyd::evald<xt::xtensor<double, 1>>( evalhyd::evald<xt::xtensor<double, 1>>(
{"NSE"}, observed_1d, forecast_1d observed_1d, forecast_1d, {"NSE"}
); );
// check results (both with 2D and 1D tensors) // check results (both with 2D and 1D tensors)
......
...@@ -24,8 +24,8 @@ TEST(ProbabilistTests, TestBrier) { ...@@ -24,8 +24,8 @@ TEST(ProbabilistTests, TestBrier) {
std::vector<xt::xtensor<double, 2>> metrics = std::vector<xt::xtensor<double, 2>> metrics =
evalhyd::evalp( evalhyd::evalp(
{"BS", "BSS", "BS_CRD", "BS_LBD"},
xt::transpose(observed), xt::transpose(forecast), xt::transpose(observed), xt::transpose(forecast),
{"BS", "BSS", "BS_CRD", "BS_LBD"},
thresholds thresholds
); );
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment