Skip to content

Commit d9c7949

Browse files
authored
Fix mutation of power of monomial (#142)
1 parent 6795fc4 commit d9c7949

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/operators.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Defining the specific methods solve this problem and also make
55
# them a lot faster
66
Base.:(^)(x::Variable{V,M}, i::Int) where {V,M} = Monomial{V,M}([x], [i])
7-
Base.:(^)(x::Monomial{<:Commutative}, i::Int) = Monomial(x.vars, i * x.z)
7+
Base.:(^)(x::Monomial{<:Commutative}, i::Int) = Monomial(copy(x.vars), i * x.z)
88

99
myminivect(x::T, y::T) where {T} = [x, y]
1010
function myminivect(x::S, y::T) where {S,T}

test/runtests.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ using LinearAlgebra
1212
@test p(x0 => y0, x1 => y1) == y1 * y0 * y1
1313
end
1414

15+
# https://github.com/JuliaAlgebra/DynamicPolynomials.jl/issues/141
16+
@testset "Issue #141" begin
17+
@polyvar x
18+
m = x^2
19+
q = m^2
20+
@test variables(q) !== variables(m)
21+
end
22+
1523
@testset "Issue #79, Issue #80 and Issue #92" begin
1624
@polyvar x[1:2]
1725
p1 = x[1] * 0.0 + x[2] * 0

0 commit comments

Comments
 (0)