xtensor
xtensor copied to clipboard
using reducers on masked_view
Hi,
There seems to be the same kind of compilation error as in #1981 with reducer functions (e.g. xt::mean
).
#include <xtensor/xtensor.hpp>
#include <xtensor/xmath.hpp>
#include <xtensor/xio.hpp>
int main(int argc, char* argv[])
{
xt::xtensor<double, 2> t
{{ 5.3, 4.2, 5.7, 2.3 },
{ 5.3, 4.2, 5.7, 2.3 },
{ 5.3, 4.2, 5.7, 2.3 }};
xt::xtensor<bool, 2> mask
{{ true, true, false, true },
{ true, true, true, true },
{ true, true, true, false }};
// compilation error
auto v = xt::masked_view(t, mask);
std::cout << xt::mean(v, 1) << std::endl;
// workaround
auto w = xt::where(mask, t, NAN);
std::cout << xt::nanmean(w, 1) << std::endl;
}
So, I am wondering whether reducers are meant to work on xt::masked_view
?
Being able to do it would be quite useful to avoid unnecessary copies (as in my workaround I think).
Thanks.