Skip to content

Commit 08abedb

Browse files
committed
Try to work around weird bug
1 parent f32d934 commit 08abedb

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/lazyconcat.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ ndims(::Applied{<:Any,typeof(hcat)}) = 2
9393
size(f::Applied{<:Any,typeof(hcat)}) = (size(f.args[1],1), +(map(a -> size(a,2), f.args)...))
9494
Base.IndexStyle(::Type{<:Hcat}) where T = Base.IndexCartesian()
9595

96-
function getindex(f::Hcat{T}, k::Integer, j::Integer) where T
96+
function hcat_getindex(f, k::Integer, j::Integer)
97+
T = eltype(f)
9798
ξ = j
9899
for A in f.args
99100
n = size(A,2)
@@ -103,6 +104,9 @@ function getindex(f::Hcat{T}, k::Integer, j::Integer) where T
103104
throw(BoundsError(f, (k,j)))
104105
end
105106

107+
getindex(f::Hcat, k::Integer, j::Integer) = hcat_getindex(f, k, j)
108+
getindex(f::Applied{DefaultArrayApplyStyle,typeof(hcat)}, k::Integer, j::Integer)= hcat_getindex(f, k, j)
109+
106110
function setindex!(f::Hcat{T}, v, k::Integer, j::Integer) where T
107111
ξ = j
108112
for A in f.args

test/concattests.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ import LazyArrays: MemoryLayout, DenseColumnMajor, PaddedLayout, materialize!, M
137137
@test vec(A) == vec(Matrix(A))
138138
@test A' == Matrix(A)'
139139
@test transpose(A) == transpose(Matrix(A))
140+
141+
@testset "getindex bug" begin
142+
A = randn(3,3)
143+
H = Hcat(A,A)
144+
@test H[1,1] == applied(hcat,A,A)[1,1] == A[1,1]
145+
end
140146
end
141147

142148
@testset "Special pads" begin

0 commit comments

Comments
 (0)