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 ba3697f commit 6273f21
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

Check warning on line 36 in src/coefficients.jl

View check run for this annotation

Codecov / codecov/patch

src/coefficients.jl#L36

Added line #L36 was not covered by tests

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

Check warning on line 55 in src/types.jl

View check run for this annotation

Codecov / codecov/patch

src/types.jl#L55

Added line #L55 was not covered by tests

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 6273f21

Please sign in to comment.