From ecacc2297742774448e78055a52270e14fa1be41 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Thu, 12 Mar 2026 10:57:16 -0400 Subject: [PATCH 1/2] Fix empty StridedView broadcasting --- src/broadcast.jl | 7 +++++-- test/othertests.jl | 8 ++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) 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)) From 65b565e7ca7224c900b6c22d5fdec3f657933393 Mon Sep 17 00:00:00 2001 From: mtfishman Date: Thu, 12 Mar 2026 11:07:18 -0400 Subject: [PATCH 2/2] Bump version --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]