-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
RFC: proposed new array assignment shape matching rule #5226
Conversation
I agree that the indexing stuff is paralyzingly complex. Needs a serious overhaul. |
This is a nicely-isolated change to the indexing code, and is an improvement worth having. Agreed that tests would be helpful, although you'll get much of that just from the functions that depend on this. |
I was looking at the problem a bit. Isn't the core logic completely symmetric? Then the symmetries can be exploited a bit. In a stylized form, where ii and jj play the role of size(X,i) and length(I[i]):
|
I too had a sense that was probably true; thanks for taking the time to check that suspicion. I'm sure you know this, but in production code for reasons of performance we need to retain the form of arguments that Jeff used. |
also reduce duplication of the related error messages
Do we need to check |
That seems to get magically handled by |
would fix #4048, #4383
This rule ignores singleton dimensions, and allows the last dimension of one side to match all trailing dimensions of the other.
The logic to implement this is pretty complicated, and I hope some code simplifications can be found. Indexing-related code always makes my brain freeze.
Right now, we don't even have a consistent rule. For example the left-hand side
A[1, 1:n]
permits different right-hand sides thanA[1:1, 1:n]
. And 1-d right-hand sides are special-cased, but the general version is to allow the last dimension of the RHS to match trailing indexes.A rule like this is safe regardless of how we decide to change the number of dimensions returned by
getindex
.EDIT: Follow-on work still needed to use this rule everywhere. Tests also needed.