Skip to content

Possible to use 1D and (N-1)D slice iteration with xt::xtensor? #2116

Open
@AntoinePrv

Description

@AntoinePrv

Description of the problem

I've tried using the examples of 1-D slice iteration and (N-1)-dimensional iteration by replacing xt::xarray<int> with xt::xtensor<int, 3> and found unexpected outcomes:

  • 1-D slice iteration (xt::axis_slice_begin1): compiles and run without errors, but all slice are empty (prints {}). Changing the axis does not change the outcome
  • (N-1)-dimensional iteration: does not compile, fails with
    xtensor/xaxis_iterator.hpp:112:24: error: no matching constructor for
      initialization of 'shape_type' (aka 'array<unsigned long, 3UL>')
            shape_type shape(e_shape.size() - 1);
    

Desired outcome

Similar iteration as xt::xarray. Eventually with compile time check on the axis (given that shape is known).

Alternative considered

Casting back and forth to an xt::xarray. I am unsure of the performance impacts, if any.

System information

This is running xtensor 0.21.5 from conda-forge and compiling on MacOs with AppleClang 11.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions