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

dump_npz does not work with bool array #173

Open
raphaelsulzer opened this issue Mar 22, 2022 · 0 comments
Open

dump_npz does not work with bool array #173

raphaelsulzer opened this issue Mar 22, 2022 · 0 comments

Comments

@raphaelsulzer
Copy link

Trying to dump a boolean array leads to the error below.
The code compiles fine if I replace the bool with int.
Is this a bug or am I doing something wrong?

vector<bool> bv = {true,false,true};
auto xbv = xt::adapt(bv);
xt::dump_npz("test.npz","test",xbv,false,false);

leads to the following error:

In file included from /usr/local/include/xtensor/xarray.hpp:20:0,
                 from /usr/local/include/xtensor/xadapt.hpp:20,
                 from /usr/local/include/xtensor/xnpy.hpp:34,
                 from /usr/local/include/xtensor-io/xnpz.hpp:30,
                 from /home/adminlocal/PhD/cpp/mesh-tools/src/IO/fileIO.h:36,
                 from /home/adminlocal/PhD/cpp/mesh-tools/src/IO/fileIO.cpp:5:
/usr/local/include/xtensor/xcontainer.hpp: In instantiation of ‘const value_type* xt::xcontainer<D>::data() const [with D = xt::xtensor_adaptor<std::vector<bool>&, 1, (xt::layout_type)1, xt::xtensor_expression_tag>; xt::xcontainer<D>::value_type = bool]’:
/usr/local/include/xtensor/xnpy.hpp:655:26:   required from ‘void xt::detail::dump_npy_stream(O&, const xt::xexpression<E2>&) [with O = xt::detail::binary_vector; E = xt::xtensor_adaptor<std::vector<bool>&, 1, (xt::layout_type)1, xt::xtensor_expression_tag>]’
/usr/local/include/xtensor-io/xnpz.hpp:480:32:   required from ‘void xt::dump_npz(std::__cxx11::string, std::__cxx11::string, const xt::xexpression<D>&, bool, bool) [with E = xt::xtensor_adaptor<std::vector<bool>&, 1, (xt::layout_type)1, xt::xtensor_expression_tag>; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/adminlocal/PhD/cpp/mesh-tools/src/IO/fileIO.cpp:774:51:   required from here
/usr/local/include/xtensor/xcontainer.hpp:578:31: error: passing ‘const storage_type {aka const std::vector<bool>}’ as ‘this’ argument discards qualifiers [-fpermissive]
         return storage().data();
                               ^
In file included from /usr/include/c++/7/vector:65:0,
                 from /usr/include/boost/property_map/vector_property_map.hpp:15,
                 from /usr/include/boost/property_map/property_map.hpp:601,
                 from /usr/local/include/CGAL/property_map.h:19,
                 from /home/adminlocal/PhD/cpp/mesh-tools/src/base/cgal_typedefs.h:6,
                 from /home/adminlocal/PhD/cpp/mesh-tools/src/IO/fileIO.cpp:1:
/usr/include/c++/7/bits/stl_bvector.h:920:5: note:   in call to ‘void std::vector<bool, _Alloc>::data() [with _Alloc = std::allocator<bool>]’
     data() _GLIBCXX_NOEXCEPT { }
     ^~~~
In file included from /usr/local/include/xtensor/xarray.hpp:20:0,
                 from /usr/local/include/xtensor/xadapt.hpp:20,
                 from /usr/local/include/xtensor/xnpy.hpp:34,
                 from /usr/local/include/xtensor-io/xnpz.hpp:30,
                 from /home/adminlocal/PhD/cpp/mesh-tools/src/IO/fileIO.h:36,
                 from /home/adminlocal/PhD/cpp/mesh-tools/src/IO/fileIO.cpp:5:
/usr/local/include/xtensor/xcontainer.hpp:578:31: error: void value not ignored as it ought to be
         return storage().data();
                               ^
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