diff --git a/src/array_partition.jl b/src/array_partition.jl index 87a66858..3d652232 100644 --- a/src/array_partition.jl +++ b/src/array_partition.jl @@ -219,6 +219,15 @@ Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Int, j...) @inbounds return b[j...] end +""" + getindex(A::ArrayPartition, i::Colon, j...) + +Returns the entry at index `j...` of every partition of `A`. +""" +Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Colon, j...) + return getindex.(A.x, (j...,)) +end + """ getindex(A::ArrayPartition, ::Colon) diff --git a/test/partitions_test.jl b/test/partitions_test.jl index 2f53f27c..7c16f6a2 100644 --- a/test/partitions_test.jl +++ b/test/partitions_test.jl @@ -58,6 +58,7 @@ copyto!(p,c) ## inference tests x = ArrayPartition([1, 2], [3.0, 4.0]) +@test x[:,1] == (1,3.0) # similar partitions @inferred similar(x)