From 6273f2112af5e10deb8422dc6b40b8a0387270a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Wed, 21 Aug 2024 13:38:02 +0200 Subject: [PATCH] Fix value_type and key_type for Tuple --- src/coefficients.jl | 3 +-- src/types.jl | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/coefficients.jl b/src/coefficients.jl index 9330350..a2b0d6c 100644 --- a/src/coefficients.jl +++ b/src/coefficients.jl @@ -33,6 +33,7 @@ key_type(b) = keytype(b) # back to `keytype{::Type{<:AbstractArray})` which returns `Int`. key_type(::Type{SparseArrays.SparseVector{V,K}}) where {V,K} = K key_type(v::SparseArrays.SparseVector) = key_type(typeof(v)) +key_type(::Tuple) = Int Base.iszero(ac::AbstractCoefficients) = isempty(keys(ac)) @@ -260,5 +261,3 @@ function MA.operate_to!( end return res end - - diff --git a/src/types.jl b/src/types.jl index e3bd5bf..7ec2dce 100644 --- a/src/types.jl +++ b/src/types.jl @@ -51,9 +51,12 @@ function MA.promote_operation(::typeof(basis), ::Type{<:AlgebraElement{A}}) wher end basis(a::AlgebraElement) = basis(parent(a)) +value_type(coeffs) = valtype(coeffs) +value_type(::NTuple{N,T}) where {N,T} = T + function AlgebraElement(coeffs, A::AbstractStarAlgebra) _sanity_checks(coeffs, A) - return AlgebraElement{typeof(A),valtype(coeffs),typeof(coeffs)}(coeffs, A) + return AlgebraElement{typeof(A),value_type(coeffs),typeof(coeffs)}(coeffs, A) end function AlgebraElement(