From e27f46e5b0e4684b65d3fbfc31ab8712af64d5f6 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Wed, 8 Jul 2026 20:51:32 +0100 Subject: [PATCH 1/2] overload copy for AdjTrans of BandedBlockBandedMatrix --- src/BandedBlockBandedMatrix.jl | 4 ++++ test/test_docstrings.jl | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/BandedBlockBandedMatrix.jl b/src/BandedBlockBandedMatrix.jl index 33b7eda..8892187 100644 --- a/src/BandedBlockBandedMatrix.jl +++ b/src/BandedBlockBandedMatrix.jl @@ -237,6 +237,10 @@ convert(::Type{AbstractMatrix{T}}, B::BandedBlockBandedMatrix) where T = _Banded convert(::Type{AbstractArray{T}}, B::BandedBlockBandedMatrix{T}) where T = B convert(::Type{AbstractMatrix{T}}, B::BandedBlockBandedMatrix{T}) where T = B +copy(A::Adjoint{T,<:BandedBlockBandedMatrix}) where T = copy(parent(A))' +copy(A::Transpose{T,<:BandedBlockBandedMatrix}) where T = transpose(copy(parent(A))) + + similar(A::BandedBlockBandedMatrix, ::Type{T}, axes::NTuple{2,AbstractUnitRange{Int}}) where T = BandedBlockBandedMatrix{T}(undef, axes, blockbandwidths(A), subblockbandwidths(A)) diff --git a/test/test_docstrings.jl b/test/test_docstrings.jl index 4fbd700..b2225c4 100644 --- a/test/test_docstrings.jl +++ b/test/test_docstrings.jl @@ -1,8 +1,5 @@ using Documenter @testset "docstrings" begin - # don't test docstrings on old versions to avoid failures due to changes in types - if VERSION >= v"1.9" - DocMeta.setdocmeta!(BlockBandedMatrices, :DocTestSetup, :(using BlockBandedMatrices); recursive=true) + DocMeta.setdocmeta!(BlockBandedMatrices, :DocTestSetup, :(using BlockBandedMatrices); recursive=true) doctest(BlockBandedMatrices) - end end From f64ae7f20f9c92d1a7c2fb1d9bd37eb7c08be152 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Fri, 10 Jul 2026 17:04:38 +0200 Subject: [PATCH 2/2] add tests --- src/BlockSkylineMatrix.jl | 4 ++++ test/test_blockskyline.jl | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/BlockSkylineMatrix.jl b/src/BlockSkylineMatrix.jl index 633ffa6..4775a58 100644 --- a/src/BlockSkylineMatrix.jl +++ b/src/BlockSkylineMatrix.jl @@ -270,6 +270,10 @@ BlockSkylineMatrix(A::Union{AbstractMatrix,UniformScaling}, rdims::AbstractVector{Int}, cdims::AbstractVector{Int}, lu::NTuple{2,AbstractVector{Int}}) = BlockSkylineMatrix{eltype(A)}(A, rdims, cdims, lu) +copy(B::BlockSkylineMatrix) = _BlockSkylineMatrix(copy(B.data), B.block_sizes) +copy(A::Adjoint{T,<:BlockSkylineMatrix}) where T = copy(parent(A))' +copy(A::Transpose{T,<:BlockSkylineMatrix}) where T = transpose(copy(parent(A))) + """ BlockBandedMatrix(A::Union{AbstractMatrix,UniformScaling}, diff --git a/test/test_blockskyline.jl b/test/test_blockskyline.jl index 5385648..aabb399 100644 --- a/test/test_blockskyline.jl +++ b/test/test_blockskyline.jl @@ -80,6 +80,32 @@ Random.seed!(0) @test OO == Matrix(O)^2 end + @testset "copy wrappers" begin + rows = [2, 1, 3] + A = BlockSkylineMatrix{Float64}(undef, rows, rows, ([0,0,0],[0,0,0])) + A.data .= reshape(1.0:length(A.data), size(A.data)) + + AC = copy(A) + @test AC isa BlockSkylineMatrix + @test AC == A + @test AC !== A + @test AC.data !== A.data + + BA = copy(adjoint(A)) + @test BA isa Adjoint{Float64,<:BlockSkylineMatrix} + @test parent(BA) isa BlockSkylineMatrix + @test BA == adjoint(Matrix(A)) + @test parent(BA) == A + @test parent(BA) !== A + + TA = copy(transpose(A)) + @test TA isa Transpose{Float64,<:BlockSkylineMatrix} + @test parent(TA) isa BlockSkylineMatrix + @test TA == transpose(Matrix(A)) + @test parent(TA) == A + @test parent(TA) !== A + end + @testset "Broadcasting" begin rows = [3, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3] l,u = [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1]