Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't reshape with shape of another pyarray #120

Closed
wolfv opened this issue Oct 30, 2017 · 0 comments
Closed

Can't reshape with shape of another pyarray #120

wolfv opened this issue Oct 30, 2017 · 0 comments

Comments

@wolfv
Copy link
Member

wolfv commented Oct 30, 2017

inline auto add(xt::pyarray<double> &a, xt::pyarray<double> &b)
{
    auto res = xt::pyarray<double>();
    res.reshape(a.shape());
    xt::noalias(res) = (a + b);
    return res;
}

fails to compile with:

src/main.cpp: In function ‘auto add(xt::pyarray<double>&, xt::pyarray<double>&)’:
src/main.cpp:26:26: error: no matching function for call to ‘xt::pyarray<double>::reshape(const inner_shape_type&)’
     res.reshape(a.shape());
                          ^
In file included from /home/wolfv/Programs/xtensor-python/include/xtensor-python/pyarray.hpp:20:0,
                 from src/main.cpp:8:
/home/wolfv/Programs/xtensor-python/include/xtensor-python/pycontainer.hpp:222:17: note: candidate: void xt::pycontainer<D>::reshape(const shape_type&) [with D = xt::pyarray<double>; xt::pycontainer<D>::shape_type = std::vector<long unsigned int>]
     inline void pycontainer<D>::reshape(const shape_type& shape)
                 ^~~~~~~~~~~~~~
/home/wolfv/Programs/xtensor-python/include/xtensor-python/pycontainer.hpp:222:17: note:   no known conversion for argument 1 from ‘const inner_shape_type {aka const xt::xbuffer_adaptor<long unsigned int>}’ to ‘const shape_type& {aka const std::vector<long unsigned int>&}’
/home/wolfv/Programs/xtensor-python/include/xtensor-python/pycontainer.hpp:236:17: note: candidate: void xt::pycontainer<D>::reshape(const shape_type&, xt::layout_type) [with D = xt::pyarray<double>; xt::pycontainer<D>::shape_type = std::vector<long unsigned int>]
     inline void pycontainer<D>::reshape(const shape_type& shape, layout_type l)
                 ^~~~~~~~~~~~~~
/home/wolfv/Programs/xtensor-python/include/xtensor-python/pycontainer.hpp:236:17: note:   candidate expects 2 arguments, 1 provided
/home/wolfv/Programs/xtensor-python/include/xtensor-python/pycontainer.hpp:249:17: note: candidate: void xt::pycontainer<D>::reshape(const shape_type&, const strides_type&) [with D = xt::pyarray<double>; xt::pycontainer<D>::shape_type = std::vector<long unsigned int>; xt::pycontainer<D>::strides_type = std::vector<long unsigned int>]
     inline void pycontainer<D>::reshape(const shape_type& shape, const strides_type& strides)
                 ^~~~~~~~~~~~~~
/home/wolfv/Programs/xtensor-python/include/xtensor-python/pycontainer.hpp:249:17: note:   candidate expects 2 arguments, 1 provided
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant