-
Notifications
You must be signed in to change notification settings - Fork 174
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
Multiple identical indexed slices are ignored #947
Comments
Ooh, yeah, that's tricky. The problem is in SlicedCopy, because it's doing a copy, it will copy the first dimension, and then overwrite it with the second dimension. Maybe an error would be best for now, until we can think of a nice way to get this to work. One option for implementing it might be to have SlicedCopy zero everything in the target buffer and then do an increment. It might be a minor performance hit, but acceptable I think. We could mitigate the performance hit by only doing this if one of the slices is a list of indices. (EDIT: or rather if the target is a list of indices) |
Looking at this again, this doesn't even work as you would think in Numpy. If you do a = np.array([-1, 0.5])
b = np.array([0.])
b[[0, 0]] += a[[0, 1]]
print(b) you get This Numpy behaviour is going to make it difficult to do in Nengo without some special-case code that could really slow things down (because I think we'd have to loop over the indices). If anyone can figure out a fast Numpy expression to do this indexing operation, then post it here and we can go from there. |
The more I think about it, the more I'm tempted to just raise an Exception if someone does this.... I can't think of a situation where I'd really want to do this, and if numpy doesn't even produce the expected behaviour, then I feel justified in just not letting people do it..... :) |
It looks like newer Numpy has a helper function The downside of using that is then we'd have different behaviour on Numpy < 1.8 and Numpy >= 1.8, or else we'd just have to stop supporting < 1.8. |
Hm... the past two stable releases of Debian (since April 26, 2015) have had at least Numpy 1.8, so I'm OK bumping up the dependency. Any objections? |
The earliest current Ubuntu release (trusty 14.04), also has 1.8, so I'm good to bump it. |
Also test that boolean indexing works. With this, advanced indexing is fully supported for ObjViews in connections. Fixes #947.
Also test that boolean indexing works. With this, advanced indexing is fully supported for ObjViews in connections. Fixes #947.
Also test that boolean indexing works. With this, advanced indexing is fully supported for ObjViews in connections. Fixes #947.
Nengo allows you to make Connections by giving a list of dimension indices
However, if you have the same index multiple times for the post part of the Connection, all but the last one are ignored:
This ignores the mapping from dimension 2 to dimension 1, and just does the mapping from dimension 3 to dimension 1.
Here is a complete example:
This model only sends the value 0.5 to the Ensemble
a
, and ignores the other dimension.I believe the correct behaviour would be to send both dimensions to a (i.e. equivalent to a transform of [[1, 1]]), but another alternative would be to throw an error saying that indexed slicing doesn't support this case.
The text was updated successfully, but these errors were encountered: