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

Support for iterating over elements of a specified axis. #2788

Open
faze-geek opened this issue May 23, 2024 · 1 comment
Open

Support for iterating over elements of a specified axis. #2788

faze-geek opened this issue May 23, 2024 · 1 comment

Comments

@faze-geek
Copy link

I wanted to support the numpy equivalent of boolean functions like ndarray.all(axis=...) / ndarray.any(axis=...) and went over the xtensor documentation. I came across xt::all() and xt::any().

I believe checking across the specified axis is not implemented for now.
@JohanMabille Do we have a alternative workaround for this as of now, or plan to support this in the future ?

@faze-geek
Copy link
Author

I see the axis argument is handled in other functions perfectly :

#include <iostream>
#include <xtensor/xarray.hpp>
#include <xtensor/xio.hpp>
#include <xtensor/xmath.hpp>

int main() {
    xt::xarray<int> arr = {{{1, 2, 3}, {4, 5, 6}},{{1, 2, 3}, {4, 5, 6}}};
    
    std::cout <<  xt::sum(arr, {0}) << std::endl;
    std::cout <<  xt::sum(arr, {1}) << std::endl;
    std::cout <<  xt::sum(arr, {2}) << std::endl;
    return 0;
}

C:\Users\kunni\gsoc-2024-dev\numpy>numpy.exe
{{ 2,  4,  6},
 { 8, 10, 12}}
{{5, 7, 9},
 {5, 7, 9}}
{{ 6, 15},
 { 6, 15}}

So axis support for xt::any() , xt::all() is a feature request at this point.

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