Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected value of xt::get_rank<xt::xtensor_adaptor>. #2786

Open
1uc opened this issue May 16, 2024 · 0 comments
Open

Unexpected value of xt::get_rank<xt::xtensor_adaptor>. #2786

1uc opened this issue May 16, 2024 · 0 comments

Comments

@1uc
Copy link

1uc commented May 16, 2024

While using xt::get_rank to detect the rank of various XTensor objects, we noticed that the following test fails:

template <class EC, size_t N, xt::layout_type L, class Tag>
void check_adapt_tensor(xt::xtensor_adaptor<EC, N, L, Tag>& x) {
    REQUIRE(xt::get_rank<decltype(x)>::value == N);
}

TEST_CASE("xt::get_rank", "[xtensor]") {
    std::array<size_t, 3> shape{3, 2, 4};
    xt::xtensor<double, 3> a(shape);
    auto a_view = xt::adapt(a.data(), a.size(), xt::no_ownership(), shape);

    check_adapt_tensor(a_view);
}

Naively, this is unexpected, because xt::xtensor_adaptor to my understanding has a compile-time constant rank and N is one of the template arguments of the class. Which is different from xt::xarray_adaptor which doesn't have a compile-time constant rank.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant