Skip to content

BUG: xt::squeeze on a xt::view using xt::range ignore the xt::range #2834

@fdegaulejac

Description

@fdegaulejac

Tested with last conan version 0.25.0

xt::xtensor<float, 2> arr1{{1.0, 2.0, 3.0}};
xt::xtensor<float, 1> arr2 = xt::squeeze(xt::view(arr1, xt::all(), xt::range(1, 3)));

Then arr2 = [1, 2] when the expected result would be [2, 3]

The problem does not occurs when assigning the view to a tensor before squeezing:

xt::xtensor<float, 2> arr3 = xt::view(arr1, xt::all(), xt::range(1, 3));
xt::xtensor<float, 1> arr4 = xt::squeeze(arr3);

Then arr4 = [2, 3]

The problem does not occur when using xt::keep instead of xt::range

xt::xtensor<float, 1> arr5 = xt::squeeze(xt::view(arr1, xt::all(), xt::keep(1, 2)));

Then arr5 = [2, 3]

Also the problem does not occur using numpy:

arr1 = np.array([[1, 2, 3]])
arr2 = np.squeeze(arr1[0, 1:3])

Then arr2 = [2, 3]

Note that we had a pretty serious hidden computation error from this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions