Commit e1f2e402 authored by Thibault Hallouin's avatar Thibault Hallouin Committed by Thibault Hallouin
Browse files

fix bug in generating masks from conditions due to NaN in series

`xt::median` and `xt::quantile` are not NaN-proof, and do not have
equivalent NaN functions (like `xt::mean` and `xt::nanmean`) so
it required a filter to drop the NaN before computing the corresponding
condition value
No related merge requests found
Pipeline #46410 passed with stage
in 3 minutes and 42 seconds
Showing with 22 additions and 10 deletions
+22 -10
......@@ -232,17 +232,29 @@ namespace evalhyd
{
return std::stod(num);
}
else if (str == "median")
{
return xt::median(q);
}
else if (str == "mean")
{
return xt::mean(q)();
}
else // (str == "qtl")
else
{
return xt::quantile(q, {std::stod(num)})();
auto q_filtered = xt::filter(q, !xt::isnan(q));
if (q_filtered.size() > 0)
{
if (str == "median")
{
return xt::median(q_filtered);
}
else if (str == "mean")
{
return xt::mean(q_filtered)();
}
else // (str == "qtl")
{
return xt::quantile(q_filtered, {std::stod(num)})();
}
}
else
{
return double(NAN);
}
}
};
......
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