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

xt::where() possibly broken in xtensor 0.23.10? #2461

Closed
emmenlau opened this issue Nov 18, 2021 · 2 comments
Closed

xt::where() possibly broken in xtensor 0.23.10? #2461

emmenlau opened this issue Nov 18, 2021 · 2 comments

Comments

@emmenlau
Copy link
Contributor

I am experiencing an issue with xt::where that I do not understand, and that seems like a bug in xtensor 0.23.10. I would assume that the following block of code give the same result for vFiltered1 and vFiltered2. That is, that xt::where() and xt::filtration() produce the same result. In godbolt with xtensor 0.19.4 this works, but locally with xtensor 0.23.10 I get all zeros for xt::where().

#include <xtensor/xtensor.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xindex_view.hpp>
#include <xtensor/xrandom.hpp>

#include <iostream>

int main() {
    xt::xtensor<double, 2> vArray = xt::cast<double>(xt::random::randint<int8_t>({4, 4}, -2, 2));
    std::cout << "vArray = " << std::endl << vArray << std::endl;

    const xt::xtensor<uint8_t, 2> vFiltered1 = xt::where(vArray < 0.0, uint8_t{1}, uint8_t{0});
    std::cout << "vFiltered1 = " << std::endl << vFiltered1 << std::endl;

    xt::xtensor<uint8_t, 2> vFiltered2 = xt::zeros<uint8_t>(vArray.shape());
    xt::filtration(vFiltered2, vArray < 0.0) = uint8_t{1};
    std::cout << "vFiltered2 = " << std::endl << vFiltered2 << std::endl;

    assert(vFiltered1 == vFiltered2);

    return 0;
}
@JohanMabille
Copy link
Member

The issue seems to be fixed in xtensor 0.24.0. Is there anything that prevents you from upgrading?

@emmenlau
Copy link
Contributor Author

emmenlau commented Nov 24, 2021

Great that its fixed, thanks @JohanMabille !

Currently I can't upgrade due to xtensor-stack/xsimd#625. But if I have the choice between the two issues, I'd rather have you look at the one with xsimd :-)

I'll close this here as fixed.

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

2 participants