★ wanayoo — archive 1999 https://github.com/xtensor-stack/xtensor-python/issues/173Nouvelle recherche | Portail wanayoo
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

fix strides_adapter #173

Open
wolfv opened this issue Oct 23, 2018 · 0 comments
Open

fix strides_adapter #173

wolfv opened this issue Oct 23, 2018 · 0 comments
Labels
Bug

Comments

@wolfv
Copy link
Member

@wolfv wolfv commented Oct 23, 2018

Currently, the strides adapter doesn't set a stride to zero if the shape in that dimension is ==1.

This leads to bugs when accessing elements of broadcasted xfunctions using explicit indexing:

    TEST(pyarray, broadcast_xfunc)
    {
        pyarray<int> a = {5,5,5,5,5};
        a.reshape({5, 1});

        pyarray<int> b = xt::arange(25);
        b.reshape({5, 5});

        auto func = a * b;

        for (std::size_t i = 0; i < 5; ++i)
        {
            for (std::size_t j = 0; j < 5; ++j)
            {
                std::cout << func(i, j) << std::endl;
            }
        }
    }
@wolfv wolfv added the Bug label Oct 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.