-
Notifications
You must be signed in to change notification settings - Fork 398
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
question about "filter" over rows/cols #1846
Comments
Maybe views can help here? auto row = xt::view(arr, 0, xt::all());
auto col = xt::view(arr, xt::all(), 0); |
in my example yes, but i meant something like this: >>> import numpy as np
>>> a = np.arange(6).reshape((2,-3))
>>> a
array([[0, 1, 2],
[3, 4, 5]])
>>> b = np.ones(3, dtype=np.bool)
>>> b[1] = False
>>> b
array([ True, False, True])
>>> c = a[:, b]
>>> c
array([[0, 2],
[3, 5]]) in other words, how to apply filter just for one dimension? |
There is actually a bug regarding the broadcasting of the condition in the You can ask explicitly for the broadcasting (it's a bit verbose but it is an acceptable workaround): xt::xarray<int> a = xt::arange(6).reshape({2, -3});
xt::xarray<bool> filter = { true, false, true };
xt::xarray<int> res = xt::filter(a, xt::broadcast(filter, a.shape())); Then you can reshape You can also use the xt::xarray<int> res = xt::view(a, xt::all(), xt::drop(2)); |
Oh, is there any plans on fixing that? Thanks for the workaround |
Well ideally we want to fix everything, it is just a matter of time and ressources ;) We are busy with the core part for now, but index views and filters should be the next big refactoring after the next release. In the meantime, if that's something urgent for you and/or if you want to contribute, feel free to open a PR, we will be happy to review it. |
How to do so? Let's say, I have an xarray and I want to get 1st col is a shape of a col ({-1,1}) and 1st row ({1,-1}). But xt::filter seems to apply bool array to whole xarray, so if we have array{2,2}, array of filter should be 4 bools in size.
Is there any way to write desired functional not like below? It's very inefficient
The text was updated successfully, but these errors were encountered: