-
-
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
Possibly undocumented behavior of indexing assignment to arrays #40018
Comments
The same (possibly undocumented) indexing behavior as in the original report persists in julia> versioninfo()
Julia Version 1.8.4
Commit 00177ebc4fc (2022-12-23 21:32 UTC)
Platform Info:
OS: Linux (x86_64-linux-gnu)
CPU: 4 × Intel(R) Core(TM) i5-6500 CPU @ 3.20GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-13.0.1 (ORCJIT, skylake)
Threads: 1 on 4 virtual cores
|
I should note that the wording of the documentation has changed slightly to the following:
However, this does not affect the problem above. |
Requesting the attention of @mbauman. |
On the forum post where I first posted this as a question, User Tamas_Papp linked to the code of the function Based on my reading of the code, it appears to me that the documentation quoted above is not a correct description of the behavior of
The behavior of I can try to work on a different version of the text that describes the behavior of The behavior of
|
I like the documented behavior significantly better than the implemented one. The behavior of
I simply missed updating this check as we changed those behaviors. So that's the how and the why... the more interesting question is the what are we gonna do about it. I don't really want to change the documentation to be more complicated here — it's already more complicated than I'd like. And I'd wager there is code in the wild relying upon, e.g., a horizontal "row vector" assignment that only works because we skip those unitary dimensions. |
Would this code error if the implementation is made consistent with the docs, or silently do the wrong thing? |
This is based on a post on the forum.
The documentation for indexing assignment says:
I am not sure if this is a bug, but the behavior in 1.5.4 (and also 1.5.3) seems to slightly different:
Now as documented,
fills
A
with ones. The behavior withs
andt
, however, is a bit puzzling. Neither of them are vectors. However,A[:, :] = s
fills
A
with zeros, even though this behavior does not seem to be documented in the quote from the “Indexing assignment” section reproduced above, ass
neither has the same dimensions asA
, nor is it a “vector”. Indeed,A[:, :] = t
raises precisely this error:
A comment on the forum by Tamas Papp also suggests that this might be undocumented behavior. More precisely, I am not sure if it is a documented feature that the assignment with
s
above should work, while the one witht
should fail. (The quote from the documentation seems to suggest both should fail with an error).The text was updated successfully, but these errors were encountered: