Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/default_term.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ monomial_type(::Type{<:Term{C,M}}) where {C,M} = M
function Base.convert(::Type{Term{T,M}}, m::AbstractMonomialLike) where {T,M}
return Term(one(T), convert(M, m))
end
function Base.convert(::Type{Term{T,M}}, t::AbstractTerm) where {T,M}
return Term{T,M}(convert(T, coefficient(t)), convert(M, monomial(t)))
end
function Base.convert(::Type{Term{T,M}}, t::Term{T,M}) where {T,M}
return t
end

function convert_constant(::Type{Term{C,M} where C}, α) where {M}
return convert(Term{typeof(α),M}, α)
end
Expand Down
4 changes: 4 additions & 0 deletions test/commutative/term.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ MP.term_type(::Type{Term2{T,M}}) where {T,M} = MP.Term{T,M}
@test_throws InexactError push!([1], 2x)
@test_throws InexactError push!([x^2], 2x)

t = MP.term(1, x)
@test convert(MP.Term{Number,MP.monomial_type(t)}, t) isa
MP.Term{Number,MP.monomial_type(t)}

@testset "Effective variables" begin
T = variable_union_type(x)
@test x isa T
Expand Down
Loading