xtensor icon indicating copy to clipboard operation
xtensor copied to clipboard

Assignment on axis_slice_range broken

Open dchansen opened this issue 2 years ago • 0 comments

Assigning on axis_slice_range (and axis_range) does not work as expected, unless the range is contiguous in memory. The code

xt::xarray<float> data = xt::empty<float>({2,3});
float test = 2.0f;
for (auto iter = xt::axis_slice_begin(data,0); iter != xt::axis_slice_end(data,0); ++iter){
    *iter = test;
}

std::cout << "Non contigious example:" << std::endl;
std::cout << data <<std::endl;

prints {{ 2., 2., 2.}, { 2., 0., 0.}} rather than {{ 2., 2., 2.}, { 2., 2., 2.}} as expected.

Full example on godbolt

dchansen avatar Apr 27 '22 12:04 dchansen