-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add fancy indexing #17
Comments
@ALMerrill |
That would be awesome! Whenever you can would be great |
Also, out of curiosity, is there a way to improve performance with the Boolean indexing? With how I’m using it, it looks like things like |
Yes, your point is correct. The code to improve performance may be here firstly. I think there are much redundant process in this code. So, i should simplify this code. |
Or use boolean as |
@ALMerrill let a = MfArray([[1, 2], [3, 4], [5, 6]])
a[MfArray([0, 1, 2]), MfArray([0, 1, 0])]
/*
mfarray =
[ 1, 4, 5], type=Int, shape=[3]
*/ numpy; >>> x = np.array([[1, 2], [3, 4], [5, 6]])
>>> x[[0, 1, 2], [0, 1, 0]]
array([1, 4, 5]) I don't know if I can implement setter... |
awesome, thank you for the update! |
@ALMerrill Setter; let a = MfArray([[1, 2], [3, 4], [5, 6]])
a[MfArray([0, 1, 2]), MfArray([0, -1, 0])] = MfArray([999,888,777])
print(a)
/*
mfarray =
[[ 999, 2],
[ 3, 888],
[ 777, 6]], type=Int, shape=[3, 2]
*/
a.T[MfArray([0, 1, -1]), MfArray([0, 1, 0])] = MfArray([-999,-888,-777])
print(a)
/*
mfarray =
[[ -999, -777],
[ 3, -888],
[ 777, 6]], type=Int, shape=[3, 2]
*/ |
Nice! That's awesome! |
Hey, I'm just curious if there are any plans to implement "fancy indexing", where you can pass a list of indeces to an MfArray, and return the items at those indeces, like in numpy. Thanks, its a great library so far.
The text was updated successfully, but these errors were encountered: