diff --git a/Project.toml b/Project.toml index f43cd14..f6bf082 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "Strided" uuid = "5e0ebb24-38b0-5f93-81fe-25c709ecae67" -version = "2.3.4" +version = "2.3.5" authors = ["Lukas Devos ", "Maarten Van Damme ", "Jutho Haegeman "] [deps] diff --git a/src/broadcast.jl b/src/broadcast.jl index 229acbb..b480a70 100644 --- a/src/broadcast.jl +++ b/src/broadcast.jl @@ -30,13 +30,16 @@ Base.dotview(a::StridedView{<:Any, N}, I::Vararg{SliceIndex, N}) where {N} = get dest::StridedView{<:Any, N}, bc::Broadcasted{StridedArrayStyle{N}} ) where {N} + dims = size(dest) + any(isequal(0), dims) && return dest + # convert to map # flatten and only keep the StridedView arguments # promote StridedView to have same size, by giving artificial zero strides - stridedargs = promoteshape(size(dest), capturestridedargs(bc)...) + stridedargs = promoteshape(dims, capturestridedargs(bc)...) c = make_capture(bc) - _mapreduce_fuse!(c, nothing, nothing, size(dest), (dest, stridedargs...)) + _mapreduce_fuse!(c, nothing, nothing, dims, (dest, stridedargs...)) return dest end diff --git a/test/othertests.jl b/test/othertests.jl index 3ca6702..8c775ce 100644 --- a/test/othertests.jl +++ b/test/othertests.jl @@ -65,6 +65,14 @@ end end end +@testset "broadcast with zero-length StridedView" begin + @testset for T in (Float32, Float64, ComplexF32, ComplexF64) + A1 = StridedView(zeros(T, (2, 0))) + A2 = StridedView(zeros(T, (2, 0))) + @test (A1 .+ A2) == StridedView(zeros(T, (2, 0))) + end +end + @testset "mapreduce with StridedView" begin @testset for T in (Float32, Float64, ComplexF32, ComplexF64) R1 = rand(T, (10, 10, 10, 10, 10, 10))