From 26130bbd8c33e0c40826980d3bec694bba0e1882 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 6 Jun 2025 11:06:54 +0100 Subject: [PATCH 1/3] Support lazy broadcasting with block arrays --- Project.toml | 2 +- ext/LazyArraysBlockArraysExt.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index ed84d550..1f3d2ae1 100644 --- a/Project.toml +++ b/Project.toml @@ -26,7 +26,7 @@ Aqua = "0.8" ArrayLayouts = "1.10.1" BandedMatrices = "1.6.2" Base64 = "1" -BlockArrays = "1.0" +BlockArrays = "1.7.0" BlockBandedMatrices = "0.13" FillArrays = "1.0" Infinities = "0.1" diff --git a/ext/LazyArraysBlockArraysExt.jl b/ext/LazyArraysBlockArraysExt.jl index 0af9a66e..ac9e10f5 100644 --- a/ext/LazyArraysBlockArraysExt.jl +++ b/ext/LazyArraysBlockArraysExt.jl @@ -13,6 +13,8 @@ import Base: getindex, BroadcastStyle, broadcasted, OneTo import BlockArrays: AbstractBlockStyle, AbstractBlockedUnitRange, blockcolsupport, blockrowsupport, BlockSlice, BlockIndexRange, AbstractBlockLayout BlockArrays._broadcaststyle(S::LazyArrays.LazyArrayStyle{1}) = S +BlockArrays.blockbroadcaststyle(S::LazyArrays.LazyArrayStyle) = S +BlockArrays.blockedbroadcaststyle(S::LazyArrays.LazyArrayStyle) = S BroadcastStyle(::LazyArrayStyle{N}, ::AbstractBlockStyle{N}) where N = LazyArrayStyle{N}() BroadcastStyle(::AbstractBlockStyle{N}, ::LazyArrayStyle{N}) where N = LazyArrayStyle{N}() From fed9aef381cc53022e239f21c1f3f45a8addff5f Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 14 Jul 2025 06:44:11 +0100 Subject: [PATCH 2/3] Update ci.yml --- .github/workflows/ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95c73680..f25ec308 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,6 +39,7 @@ jobs: - uses: julia-actions/julia-buildpkg@v1 - uses: julia-actions/julia-runtest@v1 - uses: julia-actions/julia-processcoverage@v1 + - uses: julia-actions/cache@v2 - uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} From d89417cc6a6ac551c9626e6b0577950fda90af1b Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Mon, 14 Jul 2025 10:18:05 +0100 Subject: [PATCH 3/3] Update blocktests.jl --- test/blocktests.jl | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/blocktests.jl b/test/blocktests.jl index 752af4b8..3cc5c80d 100644 --- a/test/blocktests.jl +++ b/test/blocktests.jl @@ -27,14 +27,13 @@ using BlockArrays: blockcolsupport, blockrowsupport @test axes(n,1) ≡ axes(k,1) ≡ axes(bc)[1] ≡ blockedrange(Base.OneTo(N)) u = (k .* (k .- n .- a) ./ (2k .+ (b+c-1))) @test u == (Vector(k) .* (Vector(k) .- Vector(n) .- a) ./ (2Vector(k) .+ (b+c-1))) - @test copyto!(u, bc) == (k .* (k .- n .- a) ./ (2k .+ (b+c-1))) - @test @allocated(copyto!(u, bc)) ≤ 1000 - # not clear why allocatinos so high: all allocations are coming from checking - # axes - + v = similar(u) + @test copyto!(v, bc) == (k .* (k .- n .- a) ./ (2k .+ (b+c-1))) + @test @allocated(copyto!(v, bc)) == 0 + u = BlockedArray{Float64}(undef, collect(1:N)) @test copyto!(u, bc) == (k .* (k .- n .- a) ./ (2k .+ (b+c-1))) - @test @allocated(copyto!(u, bc)) ≤ 1000 + @test @allocated(copyto!(u, bc)) == 0 end @testset "padded" begin