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

How do I take from other dimensions? #740

Open
mrocklin opened this issue Sep 13, 2016 · 1 comment
Open

How do I take from other dimensions? #740

mrocklin opened this issue Sep 13, 2016 · 1 comment

Comments

@mrocklin
Copy link

In NumPy I do this:

In [1]: import numpy as np

In [2]: x = np.arange(9).reshape((3, 3))

In [3]: x
Out[3]: 
array([[0, 1, 2],
       [3, 4, 5],
       [6, 7, 8]])

In [4]: ind = np.array([True, False, True])

In [5]: x[ind, :]
Out[5]: 
array([[0, 1, 2],
       [6, 7, 8]])

In [6]: x[:, ind]
Out[6]: 
array([[0, 2],
       [3, 5],
       [6, 8]])

In DyND-python I can get partway there

In [7]: from dynd import nd

In [8]: x = nd.array(x)

In [9]: x
Out[9]: 
nd.array([[0, 1, 2], [3, 4, 5], [6, 7, 8]],
         type="3 * 3 * int64")

In [10]: ind = nd.array(ind)

In [11]: nd.take(x, ind)
Out[11]: 
nd.array([[0, 1, 2], [6, 7, 8]],
         type="var * 3 * int64")

But don't know how to proceed to take along the other dimension.

@insertinterestingnamehere
Copy link
Member

@izaid any comments here?

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