Skip to content

Commit d9a3a7a

Browse files
Merge pull request #281 from mateuszbaran/mbaran/fix-273
Fix Cartesian indexing into ArrayPartition
2 parents aeb2dde + a9f5e23 commit d9a3a7a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/array_partition.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ function Base._unsafe_getindex(::IndexStyle, A::ArrayPartition,
264264
return dest
265265
end
266266

267+
Base._maybe_reshape(::IndexCartesian, A::ArrayPartition, I::Vararg{Union{Real, AbstractArray}, N}) where {N} = Vector(A)
268+
267269
"""
268270
setindex!(A::ArrayPartition, v, i::Int, j...)
269271

test/partitions_test.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,4 +241,8 @@ end
241241
a = ArrayPartition(TypeChangingArray{Int, 2}(), TypeChangingArray{Float32, 2}())
242242
@test copy(a) == ArrayPartition(zeros(Int, 0, 0), zeros(Float32, 0, 0))
243243
@test zero(a) == ArrayPartition(zeros(Int, 0, 0), zeros(Float32, 0, 0))
244-
end
244+
end
245+
246+
@testset "Cartesian indexing" begin
247+
@test ArrayPartition([1,2], [3])[1:3,1] == [1, 2, 3]
248+
end

0 commit comments

Comments
 (0)