Skip to content
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

Fix linear indexing of one-dimensional CartesianIndices #28401

Merged
merged 1 commit into from
Aug 2, 2018

Conversation

timholy
Copy link
Member

@timholy timholy commented Aug 2, 2018

This fixes some surprising outcomes:

julia> ci = CartesianIndices((2:4,))
3-element CartesianIndices{1,Tuple{UnitRange{Int64}}}:
 CartesianIndex(2,)
 CartesianIndex(3,)
 CartesianIndex(4,)

julia> show(ci)
CartesianIndex{1}[CartesianIndex(3,), CartesianIndex(4,), #undef]
julia> collect(ci)
3-element Array{CartesianIndex{1},1}:
 CartesianIndex(2,)
 CartesianIndex(3,)
 CartesianIndex(4,)

julia> collect(LinearIndices(ci))
3-element Array{Int64,1}:
 1
 2
 3

julia> for i in LinearIndices(ci)
           @show i
       end
i = 2
i = 3
i = 4

CC @mbauman

The distinction between the values and the axes can be tricky
Copy link
Member

@mbauman mbauman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mac failure is the old FileWatching issue, #26725.

@StefanKarpinski StefanKarpinski merged commit 2c08695 into master Aug 2, 2018
@StefanKarpinski StefanKarpinski deleted the teh/fix_li branch August 2, 2018 12:44
KristofferC pushed a commit that referenced this pull request Feb 11, 2019
The distinction between the values and the axes can be tricky
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants