xtensor-io icon indicating copy to clipboard operation
xtensor-io copied to clipboard

Add test to assign chunked array to chunked array

Open davidbrochart opened this issue 5 years ago • 7 comments

davidbrochart avatar Dec 15 '20 22:12 davidbrochart

Looks like we can't assign an xarray to a chunked file array.

davidbrochart avatar Dec 15 '20 23:12 davidbrochart

OK so this is because:

// not correct:
auto a = xt::arange(4 * 4).reshape({4, 4});
// correct:
auto a = xt::arange(4 * 4);
a.reshape({4, 4});

This is a different behavior than NumPy, where you do:

a = np.arange(4 * 4).reshape(4, 4)

davidbrochart avatar Dec 16 '20 01:12 davidbrochart

/usr/share/miniconda/envs/xtensor-io/include/xtensor/xnoalias.hpp:165:32: error: invalid initialization of non-const reference of type 'xt::xchunked_array<xt::xchunk_store_manager<xt::xfile_array_container<xt::xarray_container<xt::uvector<double, std::allocator<double> >, xt::layout_type::row_major, xt::svector<long unsigned int, 4, std::allocator<long unsigned int>, true>, xt::xtensor_expression_tag>, xt::xio_disk_handler<xt::xio_binary_config> >, xt::xindex_path>, xt::empty_extension>&' from an rvalue of type 'void'
  165 |         return m_array.assign(e);
      |               

davidbrochart avatar Dec 16 '20 02:12 davidbrochart

The root cause is that noalias does not work with chunked_array. This has to be fixed in xtensor.

JohanMabille avatar Dec 16 '20 15:12 JohanMabille

https://github.com/xtensor-stack/xtensor/pull/2256 should fix it.

JohanMabille avatar Dec 16 '20 16:12 JohanMabille

xtensor-stack/xtensor#2256 should fix it.

It fixes it. I'll remove the dependency on master in this PR when we get an xtensor release.

davidbrochart avatar Dec 17 '20 18:12 davidbrochart

Let's fix it after the release.

JohanMabille avatar Jan 20 '21 21:01 JohanMabille