think this is the template type returned: xt::xarray_adaptor<xt::xbuffer_adaptor<double *, xt::no_ownership, std::allocator<double>>, xt::layout_type::row_major, std::vector<pybind11::ssize_t, std::allocator<pybind11::ssize_t>>, xt::xtensor_expression_tag>
I would prefer if it could just be xt:xarray. But I guess it might not be possible to turn a cstyle array into xt::xarray. I guess I have to carry around that type althrough out my code....
phmalek @phmalek 13:01
If you want to know the types only to write the appropriate function, use templates. I refere you to one of my previous issues. You can use templates for your function inputs:
template <class T>
int func2(const T& b)
{
//Do something with b
auto b_sub = xt::view(b, xt::keep(indices), xt::all());
auto mean = xt::mean(b_sub,0);
return something;
}
int func1(xt::pyarray<float>& a)
{
auto a_sub = xt::view(a, xt::keep(indices), xt::all());
int result = func2(a_sub);
return result;
}
int func2_py(xt::pyarray<float> b)
{
return func2(b);
}
PYBIND11_MODULE(example, m)
{
xt::import_numpy();
m.def("func1",func1);
m.def("func2_py",func2_py);
}
_
Created
May 23, 2019 23:02
-
-
Save phaustin/ee5385265c0ae9a11a843dbbd734c3dc to your computer and use it in GitHub Desktop.
xtensor_templates
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment