-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
See also axes
from eachindex
's docstring, etc.
#45356
Conversation
axes
from eachindex
's docstring, etc.axes
from eachindex
's docstring, etc.
@@ -308,17 +311,21 @@ if all inputs have fast linear indexing, a [`CartesianIndices`](@ref) | |||
otherwise). | |||
If the arrays have different sizes and/or dimensionalities, a `DimensionMismatch` exception |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside, I'm not sure what "and/or" means, but I don't think this describes the actual behaviour:
julia> eachindex([1,2,3], [1 2 3]) # size (3,) and (1, 3) accepted
Base.OneTo(3)
julia> eachindex([1,2,3], [1 2 3]') # size (3,) and (3,1) not accepted here
ERROR: DimensionMismatch: all inputs to eachindex must have the same axes
julia> eachindex([1,2,3], [1;2;3;;]) # size (3,) and (3,1) now accepted, as both prefer linear indexing?
Base.OneTo(3)
julia> eachindex([1;2;3;;], [1 2 3]') # both size (3,1), but different eachindex
CartesianIndices((3, 1))
Is this what's intended? And how should it then be described?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In English "or" often means xor
, so "and/or" disambiguates that case. It's a bit awkward.
https://en.wikipedia.org/wiki/And/or
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, although it still seems an odd choice to describe computer logic, not a menu. And if differing dimensionalities means ndims
, that implies differing size
anyway.
While differing size
might be necessary for an error, it's not sufficient. Can we describe the actual behaviour accurately? Or are some of those bugs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Can this be merged? |
Bump? |
As suggested here: https://discourse.julialang.org/t/eachindex-for-individual-axes-of-multidimensional-arrays/81264/5