Skip to content

xtensor concatenate behavior differs much from numpy when only concatenate one element #2260

@WymanY

Description

@WymanY

when use numpy like this:

a = np.arange(24).reshape(2,3,2,2)
//it produces
array([[[[ 0,  1],
         [ 2,  3]],

        [[ 4,  5],
         [ 6,  7]],

        [[ 8,  9],
         [10, 11]]],


       [[[12, 13],
         [14, 15]],

        [[16, 17],
         [18, 19]],

        [[20, 21],
         [22, 23]]]])

np.concatenate(a,1)
//it produces this
array([[[ 0,  1],
        [ 2,  3],
        [12, 13],
        [14, 15]],

       [[ 4,  5],
        [ 6,  7],
        [16, 17],
        [18, 19]],

       [[ 8,  9],
        [10, 11],
        [20, 21],
        [22, 23]]])

//when use xtensor
xt::xarray<int>a = xt::arange<int>(24).reshape({2,3,4,4})
xt::concatenate(xt::xtuple(),1);

//it proudces itself, do nothing.

I have no idea how to make xtensor's concatencat behave like numpy or achieve this effect. I am a newbie for c++. I tried a lot, but to no avail.

If you have any good way, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions