You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have some documentation on the use of Slice, LinearIndices and CartesianIndices for non-1-based indexing.
For instance I just found out in #28503 that the following works:
julia> li =LinearIndices((Base.Slice(1:128), Base.Slice(0:127)))
julia> li[1,0]
1
Until then I had unsuccessfully tried the following:
julia> li =LinearIndices((1:128, 0:127))
julia> li =LinearIndices((1:128, ZeroRange(128)))
which both give
julia> li[1,0]
ERROR: BoundsError: attempt to access 128×128 LinearIndices{2,Tuple{UnitRange{Int64},UnitRange{Int64}}} at index [1, 0]
But I can't find any official docs on Slice or why it works differently from ZeroRange and UnitRange, or an explanation of the rationale for the implicit 1-based conversions.
Example of things I would have liked to find in the docs:
what design choices require that LinearIndices((0:9,0:9)) == LinearIndices((1:10, 1:10))?
Yes, this can and should be improved. Quick comment right off the bat: you want to use Base.IdentityUnitRange instead of Base.Slice. I'll try to add more later, but some details are in discourse:
It would be nice to have some documentation on the use of
Slice
,LinearIndices
andCartesianIndices
for non-1-based indexing.For instance I just found out in #28503 that the following works:
Until then I had unsuccessfully tried the following:
which both give
But I can't find any official docs on
Slice
or why it works differently fromZeroRange
andUnitRange
, or an explanation of the rationale for the implicit 1-based conversions.Example of things I would have liked to find in the docs:
what design choices require that
LinearIndices((0:9,0:9)) == LinearIndices((1:10, 1:10))
?if I can do:
is there a built-in way to construct an expression
SomeIndices
such that:other than allocating a complete
OffsetArray
with the indices?Maybe this belongs to the dev/offset arrays docs?
The text was updated successfully, but these errors were encountered: