Skip to content

Commit

Permalink
Merge pull request #13 from ranocha/pull-request/76cae0a5
Browse files Browse the repository at this point in the history
getindex(A::AbstractArray, ::Val{:..})
  • Loading branch information
ChrisRackauckas authored Oct 20, 2017
2 parents 5f5ff74 + 76cae0a commit 787a2ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/EllipsisNotation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ const .. = Val{:..}()
to_indices(A, inds, (colons..., tail(I)...))
end

# avoid copying if indexing with .. alone, see
# https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/issues/214
@inline Base.getindex(A::AbstractArray, ::Val{:..}) = A

export ..

end # module
15 changes: 14 additions & 1 deletion test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,17 @@ B = [3 4

@test B == reshape(A[1,..],4,2) == reshape(view(A, 1,..), 4, 2)

@test A[:,1,2] == A[..,1,2] == @view A[..,1,2]
@test A[:,1,2] == A[..,1,2] == @view A[..,1,2]

# [..]
C = zeros(B)

C[:] = B[..]
@test B == C
C[1,1] += 1
@test B != C

C[..] = B[..]
@test B == C
C[1,1] += 1
@test B != C

0 comments on commit 787a2ed

Please sign in to comment.