Skip to content

Commit befe4a0

Browse files
authored
Support empty Hcat (#353)
1 parent ea30a91 commit befe4a0

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "LazyArrays"
22
uuid = "5078a376-72f3-5289-bfd5-ec5146d43c02"
3-
version = "2.2.3"
3+
version = "2.2.4"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/lazyconcat.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,13 @@ reverse(f::Vcat{<:Any,1}) = Vcat((reverse(itr) for itr in reverse(f.args))...)
129129
const Hcat{T,I<:Tuple} = ApplyArray{T,2,typeof(hcat),I}
130130

131131
Hcat(A...) = ApplyArray(hcat, A...)
132+
Hcat() = Hcat{Any}()
132133
Hcat{T}(A...) where T = ApplyArray{T}(hcat, A...)
133134

134135
@inline applied_eltype(::typeof(hcat), args...) = promote_type(map(eltype,args)...)
135136
@inline applied_ndims(::typeof(hcat), args...) = 2
136137
@inline applied_size(::typeof(hcat), args...) = (size(args[1],1), +(map(a -> size(a,2), args)...))
138+
@inline applied_size(::typeof(hcat)) = (0,0)
137139

138140
@inline hcat_getindex(f, k, j::Integer) = hcat_getindex_recursive(f, (k, j), f.args...)
139141

test/concattests.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,11 @@ import LazyArrays: MemoryLayout, DenseColumnMajor, materialize!, call, paddeddat
647647
A = Applied(hvcat, 2, A, B, C, D)
648648
@test A[1,2] == M[1,2]
649649
end
650+
651+
@testset "1 arg Vcat/Hcat" begin
652+
@test Array(Hcat()) == Array{Any}(undef,0,0)
653+
@test rowsupport(Hcat(Vcat(Zeros(3,1))),1:2) == colsupport(Vcat(Hcat(Zeros(1,3))),1:2)
654+
end
650655
end
651656

652657
end # module

0 commit comments

Comments
 (0)