diff --git a/src/polynomial.jl b/src/polynomial.jl index 879cfcf..55d2c4e 100644 --- a/src/polynomial.jl +++ b/src/polynomial.jl @@ -66,6 +66,8 @@ function Base.isequal(p::Polynomial{B}, q::Polynomial{B}) where {B} return isequal(p.monomial, q.monomial) end +Base.isone(p::Polynomial) = isone(p.monomial) + # Needed for `BoundsError` Base.iterate(p::Polynomial) = p, nothing Base.iterate(::Polynomial, ::Nothing) = nothing diff --git a/test/monomial.jl b/test/monomial.jl index 2f55d4f..24e569e 100644 --- a/test/monomial.jl +++ b/test/monomial.jl @@ -7,11 +7,14 @@ using DynamicPolynomials @testset "StarAlgebras" begin @polyvar x a = MB.Polynomial{MB.Monomial}(x) + @test !isone(a) b = a * a @test b.coeffs == sparse_coefficients(x^2) @test typeof(b.coeffs) == typeof(sparse_coefficients(x^2)) @test MB.Polynomial{MB.Monomial}(x^2) == MB.Polynomial{MB.Monomial}(x^2) @test MB.Polynomial{MB.Monomial}(x^3) != MB.Polynomial{MB.Monomial}(x^2) + o = MB.Polynomial{MB.Monomial}(constant_monomial(x^2)) + @test isone(o) end @testset "Linear" begin