Skip to content

Commit

Permalink
Fix value_type and key_type for Tuple
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Aug 21, 2024
1 parent 8a6e2dd commit da06c6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/coefficients.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -260,5 +261,3 @@ function MA.operate_to!(
end
return res
end


5 changes: 4 additions & 1 deletion src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit da06c6d

Please sign in to comment.