Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
blegat committed Jun 17, 2024
1 parent 11ef17b commit c6c6b7e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/MultivariateBases.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ function MP.polynomial_type(::Type{<:Algebra{B}}, ::Type{T}) where {B,T}
return MP.polynomial_type(B, T)
end
SA.basis(a::Algebra) = a.basis
MA.promote_operation(::typeof(SA.basis), ::Type{<:Algebra{B}}) where {B} = B
# Is this needed ?
#MA.promote_operation(::typeof(SA.basis), ::Type{<:Algebra{B}}) where {B} = B

#Base.:(==)(::Algebra{BT1,B1,M}, ::Algebra{BT2,B2,M}) where {BT1,B1,BT2,B2,M} = true
#Base.:(==)(::Algebra, ::Algebra) = false
Expand Down Expand Up @@ -64,13 +65,14 @@ function algebra(
return Algebra{typeof(basis),B,M}(basis)
end

function MA.promote_operation(
::typeof(algebra),
BT::Type{
<:Union{QuotientBasis{Polynomial{B,M}},FullBasis{B,M},SubBasis{B,M}},
},
) where {B,M}
return Algebra{BT,B,M}
end
# Needed ?
#function MA.promote_operation(
# ::typeof(algebra),
# BT::Type{
# <:Union{QuotientBasis{Polynomial{B,M}},FullBasis{B,M},SubBasis{B,M}},
# },
#) where {B,M}
# return Algebra{BT,B,M}
#end

end # module
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
@polyvar x[1:2]
M = typeof(prod(x))
full_basis = FullBasis{B,M}()
@test sprint(show, MB.algebra(full_basis)) == "Polynomial algebra of $B basis"
for basis in [
maxdegree_basis(full_basis, x, degree),
explicit_basis_covering(
Expand All @@ -34,6 +35,11 @@ function api_test(B::Type{<:MB.AbstractMonomialIndexed}, degree)
@test polynomial_type(basis, Float64) == polynomial_type(x[1], Float64)
#@test polynomial(i -> 0.0, basis) isa polynomial_type(basis, Float64)
end
p = MB.Polynomial{B}(x[1]^2)
@test polynomial_type(x[1]^2, String) == polynomial_type(typeof(p), String)
a = MB.algebra_element(p)
@test typeof(polynomial(a)) == polynomial_type(typeof(a))
@test typeof(polynomial(a)) == polynomial_type(typeof(p), Int)
end

function univ_orthogonal_test(
Expand Down

0 comments on commit c6c6b7e

Please sign in to comment.