Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dlfivefifty committed Jul 19, 2023
1 parent 7905029 commit c834fb7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BandedMatrices"
uuid = "aae01518-5342-5314-be14-df237901396f"
version = "0.17.30"
version = "0.17.31"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
12 changes: 8 additions & 4 deletions src/banded/BandedMatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,15 @@ convert(::Type{DefaultBandedMatrix}, M::AbstractMatrix{T}) where T = convert(Def

copy(B::BandedMatrix) = _BandedMatrix(copy(B.data), B.raxis, B.l, B.u)

LinearAlgebra.copymutable_oftype(B::BandedMatrix, ::Type{S}) where S =
_BandedMatrix(LinearAlgebra.copymutable_oftype(B.data, S), B.raxis, B.l, B.u)
if isdefined(LinearAlgebra, :copymutable_oftype)
LinearAlgebra.copymutable_oftype(B::BandedMatrix, ::Type{S}) where S =

Check warning on line 152 in src/banded/BandedMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/banded/BandedMatrix.jl#L152

Added line #L152 was not covered by tests
_BandedMatrix(LinearAlgebra.copymutable_oftype(B.data, S), B.raxis, B.l, B.u)

LinearAlgebra.copymutable_oftype(B::Adjoint{<:Any,<:BandedMatrix}, ::Type{S}) where S =
LinearAlgebra.copymutable_oftype(parent(B), S)'
LinearAlgebra.copymutable_oftype(B::Adjoint{<:Any,<:BandedMatrix}, ::Type{S}) where S =

Check warning on line 155 in src/banded/BandedMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/banded/BandedMatrix.jl#L155

Added line #L155 was not covered by tests
LinearAlgebra.copymutable_oftype(parent(B), S)'
LinearAlgebra.copymutable_oftype(B::Transpose{<:Any,<:BandedMatrix}, ::Type{S}) where S =

Check warning on line 157 in src/banded/BandedMatrix.jl

View check run for this annotation

Codecov / codecov/patch

src/banded/BandedMatrix.jl#L157

Added line #L157 was not covered by tests
transpose(LinearAlgebra.copymutable_oftype(parent(B), S))
end

promote_rule(::Type{BandedMatrix{T1, C1}}, ::Type{BandedMatrix{T2, C2}}) where {T1,C1, T2,C2} =
BandedMatrix{promote_type(T1,T2), promote_type(C1, C2)}
Expand Down
12 changes: 12 additions & 0 deletions test/test_banded.jl
Original file line number Diff line number Diff line change
Expand Up @@ -505,4 +505,16 @@ Base.similar(::MyMatrix, ::Type{T}, m::Int, n::Int) where T = MyMatrix{T}(undef,
@test @view(p[2:3]) == 2:3
end
end

if isdefined(LinearAlgebra, :copymutable_oftype)
@testset "copymutable_oftype" begin
B = _BandedMatrix((2:3)', 4, -2, 2)
@test LinearAlgebra.copymutable_oftype(B, Float64) == B
@test LinearAlgebra.copymutable_oftype(B, Float64) isa BandedMatrix{Float64}
@test LinearAlgebra.copymutable_oftype(B', Float64) == B'
@test LinearAlgebra.copymutable_oftype(B', Float64) isa Adjoint{Float64,<:BandedMatrix{Float64}}
@test LinearAlgebra.copymutable_oftype(transpose(B), Float64) == transpose(B)
@test LinearAlgebra.copymutable_oftype(transpose(B), Float64) isa Transpose{Float64,<:BandedMatrix{Float64}}
end
end
end

0 comments on commit c834fb7

Please sign in to comment.