- Notifications
You must be signed in to change notification settings - Fork338
Impl NdIndex<IxDyn> for &Vec<Ix> and Vec<Ix>#1146
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Thanks for the PR. I agree that it may be worth adding @bluss What do you think? Fwiw, this currently works with letmut a =ArrayD::<f32>::zeros(vec![1,2]);let index =vec![0,0];a[&*index] =1.0; (Note the extra If Regarding the implementation -- I'd suggest converting to |
Many thanks for the comments. The PR now adds implementations for |
Uh oh!
There was an error while loading.Please reload this page.
This change attempts to improve the ergonomics of indexing dynamic dimension arrays.
Let's say we have:
(Of course, in practice, the number of dims is dynamic.)
Then currently we can't do
a[&index] = 1.0
ora[index] = 1.0
. Instead we seem to need to doThis change makes the first two methods of indexing possible.
I'm new to
ndarray
, so there may be a discussion on this somewhere that I haven't seen. The new impls were created by copying the impl of &[Ix] (for &Vec) and by modifying the impl of &[Ix] (for Vec).I can add tests for this if it looks useful?