Description
openedon Feb 25, 2014
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 of A[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 array A
, A[:,:]
produces 2d output, A[3,:]
and A[:,3]
both produce 1d output, and A[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.