From 7f17590e35ec15d0748bb2dd4972f122e06f43e8 Mon Sep 17 00:00:00 2001 From: Marek Kaluba Date: Wed, 15 May 2024 05:07:28 +0200 Subject: [PATCH] increase coverage by removing old methods --- src/bases.jl | 2 -- src/bases_fixed.jl | 1 - src/coefficients.jl | 4 +++- src/mstructures.jl | 2 -- src/star.jl | 1 - test/abstract_coeffs.jl | 3 +++ test/caching_allocations.jl | 5 +++++ 7 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/bases.jl b/src/bases.jl index afd5951..1d4cf65 100644 --- a/src/bases.jl +++ b/src/bases.jl @@ -47,8 +47,6 @@ Explicit bases are stored e.g. in an `AbstractVector` and hence immutable """ abstract type ExplicitBasis{T,I} <: AbstractBasis{T,I} end -Base.keys(ib::ExplicitBasis) = Base.OneTo(length(ib)) - function zero_coeffs(::Type{S}, eb::ExplicitBasis{T,I}) where {S,T,I} return spzeros(S, I, length(eb)) end diff --git a/src/bases_fixed.jl b/src/bases_fixed.jl index ce302b7..e0e0ab3 100644 --- a/src/bases_fixed.jl +++ b/src/bases_fixed.jl @@ -32,7 +32,6 @@ Base.length(b::FixedBasis) = length(b.elts) Base.iterate(b::FixedBasis) = iterate(b.elts) Base.iterate(b::FixedBasis, state) = iterate(b.elts, state) -Base.IndexStyle(::Type{<:FixedBasis{T,I,V}}) where {T,I,V} = Base.IndexStyle(V) # To break ambiguity Base.@propagate_inbounds Base.getindex( diff --git a/src/coefficients.jl b/src/coefficients.jl index f60c23f..df104f9 100644 --- a/src/coefficients.jl +++ b/src/coefficients.jl @@ -15,7 +15,7 @@ For general types either all necessary arithmetic operations need to be implemented, or fallbacks using the framework of `MutableArithmetics` are provided based on random indexing. Additionally one needs to provide: -* `Base.similar(ac, T::)` with the same semantics as the one for vectors +* `Base.similar(ac, T::Type)` with the same semantics as the one for vectors * `Base.getindex(ac, idx)` * `Base.setindex!(ac, val, idx)` * `MutableArithmetics.operate!(ms::UnsafeAddMul, ac, v::C, w::C) where C<:SA.AbstractCoefficients` @@ -36,6 +36,8 @@ key_type(v::SparseArrays.SparseVector) = key_type(typeof(v)) Base.iszero(ac::AbstractCoefficients) = isempty(keys(ac)) +Base.similar(ac::AbstractCoefficients) = similar(ac, valtype(ac)) + """ canonical(ac::AbstractCoefficients) Compute the canonical form of `ac` (e.g. grouping coefficients together, etc). diff --git a/src/mstructures.jl b/src/mstructures.jl index 8c288f4..d0fc193 100644 --- a/src/mstructures.jl +++ b/src/mstructures.jl @@ -83,8 +83,6 @@ struct DiracMStructure{Op} <: MultiplicativeStructure op::Op end -DiracMStructure() = DiracMStructure(*) - function (mstr::DiracMStructure)(x::T, y::T) where {T} xy = mstr.op(x, y) return SparseCoefficients((xy,), (1,)) diff --git a/src/star.jl b/src/star.jl index 6735dd9..b0e971d 100644 --- a/src/star.jl +++ b/src/star.jl @@ -7,7 +7,6 @@ function star(X::AlgebraElement) end star(::AbstractBasis, x) = star(x) -star(basis::ImplicitBasis, i::Integer) = basis[-i] function star(basis::AbstractBasis, d::SparseCoefficients) k = star.(Ref(basis), keys(d)) diff --git a/test/abstract_coeffs.jl b/test/abstract_coeffs.jl index 0c31e7d..a1b9df9 100644 --- a/test/abstract_coeffs.jl +++ b/test/abstract_coeffs.jl @@ -75,6 +75,9 @@ end fP2 = (α + β) // 2 @test coeffs(fP2) isa ACoeffs{<:Rational} + @test SA.key_type(coeffs(fP2)) == UInt32 + @test zero(coeffs(fP2)) == ACoeffs(coeffs(zero(P), basis(fRG))) + P3 = 2 * sum(RG(g) for g in basis(RG) if sign(g) > 0) // l fP3 = AlgebraElement(ACoeffs(coeffs(P3, basis(fRG))), fRG) @test AlgebraElement(coeffs(fP3, basis(RG)), RG) == P3 diff --git a/test/caching_allocations.jl b/test/caching_allocations.jl index bce3c0f..cab2114 100644 --- a/test/caching_allocations.jl +++ b/test/caching_allocations.jl @@ -36,6 +36,10 @@ end @test Y * one(fRG) == Y @test one(fRG) * Y == Y + @test_throws SA.UndefRefError all(!iszero, SA.mstructure(fRG).table) + mstr = deepcopy(SA.mstructure(fRG)) + SA.complete!(mstr) + @test all(!iszero(mstr.table)) @test_throws SA.UndefRefError all(!iszero, SA.mstructure(fRG).table) @static if v"1.10" ≤ VERSION < v"1.11" @@ -52,6 +56,7 @@ end @test all(!iszero, SA.mstructure(fRG).table) + @static if v"1.10" ≤ VERSION < v"1.11" YY = deepcopy(Y) _alloc_test(YY, *, Y, Y, 25)