-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
drop dimensions indexed with a scalar? #5949
Copy link
Copy link
Closed
Labels
breakingThis change will break codeThis change will break codeneeds decisionA decision on this change is neededA decision on this change is neededspeculativeWhether the change will be implemented is speculativeWhether the change will be implemented is speculative
Metadata
Metadata
Assignees
Labels
breakingThis change will break codeThis change will break codeneeds decisionA decision on this change is neededA decision on this change is neededspeculativeWhether the change will be implemented is speculativeWhether the change will be implemented is speculative
Type
Fields
Give feedbackNo fields configured for issues without a type.
It seems likely that 0.4 will see a transition to array views (#5556). This change will surely break some code, e.g., for anyone who was relying on the behavior of
setindex!applied to the output ofA[3:15, 7]. Perhaps we should take the occasion to simultaneously think about another (much worse) breakage.As we've gotten less concerned about breaking Matlab compatibility (and as I've learned more about the wider scientific ecosystem), I've increasingly begun to wonder whether NumPy's slicing rules are the right way to go. It's very simple: if you index along a particular dimension with an
AbstractVector, that dimension is retained; if you index with a scalar, that dimension is dropped. So for a 2d arrayA,A[:,:]produces 2d output,A[3,:]andA[:,3]both produce 1d output, andA[3:3,:],A[:,3:3]both produce 2d output. Note this scheme is type-stable, so AFAICT there are no performance gotchas.But wow would it be a breaking change.