-
-
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
size padding: document or remove #23985
Comments
Since you can index with arbitrary trailing 1s the size in that dimension is 1. I don't see a reason to change this.
|
You are right about Even though I don't understand the rationale behind 1-padding, because I could not find any discussion of this, I recognize if others find it useful (I am just really curious about examples — this would be a good place to discuss). But in that case, it should be made part of the interface requirements for |
I have a recent amusing anecdote where it cost me a couple of hours of confusion because I mistakenly had a Another point is that it sort of makes sense to expect |
I also get today confused about this behavior. I think it should be an info about this in the doc. |
Size padding, ie
size(x, i) == 1
wheni > ndims(x)
, was introduced with db7df14, in response to #306. Both the issue and the fix predate the Arraypocalypse and related redesign by 3 years (!), yet this feature has survived subsequent redesign.I am unsure about the utility of this feature, and I am not convinced that is has received enough discussion — I would rather have
size(x, i)
be equivalent tosize(x)[i]
, and get aBoundsError
. However, if it is deemed useful after some discussion, then it should be at least documented.Also, a decision should be made about whether implementations of the array interface should pad with
1
s, throw an error, or do whatever they like. Of course, if unimplemented, it will default to the above method with padding for subtypes ofAbstractArray
.Many types inBase
implementsize(A, i)
by throwing an error if outsidendims(A)
. EgUmfpackLU
,LQPackedQ
,Bidiagonal
,Diagonal
,SymTridiagonal
,Tridiagonal
,BitVector
,Bidiagonal
(list not necessarily complete, just did a simple grep). Many packages also do it, too numerous to list here.The text was updated successfully, but these errors were encountered: