From d9c7949742593bbcae7db1ef340b3c1868f8f13a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Legat?= Date: Fri, 8 Sep 2023 21:10:17 +0200 Subject: [PATCH] Fix mutation of power of monomial (#142) --- src/operators.jl | 2 +- test/runtests.jl | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/operators.jl b/src/operators.jl index 1a7d0cb..fdd2fd4 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -4,7 +4,7 @@ # Defining the specific methods solve this problem and also make # them a lot faster Base.:(^)(x::Variable{V,M}, i::Int) where {V,M} = Monomial{V,M}([x], [i]) -Base.:(^)(x::Monomial{<:Commutative}, i::Int) = Monomial(x.vars, i * x.z) +Base.:(^)(x::Monomial{<:Commutative}, i::Int) = Monomial(copy(x.vars), i * x.z) myminivect(x::T, y::T) where {T} = [x, y] function myminivect(x::S, y::T) where {S,T} diff --git a/test/runtests.jl b/test/runtests.jl index 5551b82..7226e2d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,6 +12,14 @@ using LinearAlgebra @test p(x0 => y0, x1 => y1) == y1 * y0 * y1 end +# https://github.com/JuliaAlgebra/DynamicPolynomials.jl/issues/141 +@testset "Issue #141" begin + @polyvar x + m = x^2 + q = m^2 + @test variables(q) !== variables(m) +end + @testset "Issue #79, Issue #80 and Issue #92" begin @polyvar x[1:2] p1 = x[1] * 0.0 + x[2] * 0