Skip to content

Commit a5faa0d

Browse files
Merge pull request #239 from SciML/colon_index
Fix (colon,j...) indexing of ArrayPartition
2 parents 8f61ca4 + 1ce74b8 commit a5faa0d

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/array_partition.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,15 @@ Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Int, j...)
219219
@inbounds return b[j...]
220220
end
221221

222+
"""
223+
getindex(A::ArrayPartition, i::Colon, j...)
224+
225+
Returns the entry at index `j...` of every partition of `A`.
226+
"""
227+
Base.@propagate_inbounds function Base.getindex(A::ArrayPartition, i::Colon, j...)
228+
return getindex.(A.x, (j...,))
229+
end
230+
222231
"""
223232
getindex(A::ArrayPartition, ::Colon)
224233

test/partitions_test.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ copyto!(p,c)
5858
## inference tests
5959

6060
x = ArrayPartition([1, 2], [3.0, 4.0])
61+
@test x[:,1] == (1,3.0)
6162

6263
# similar partitions
6364
@inferred similar(x)

0 commit comments

Comments
 (0)