JuliaAlgebra / DynamicPolynomials.jl

Multivariate polynomials implementation of commutative and non-commutative variables
Other
60 stars 21 forks source link

error from substitution #96

Closed chriscoey closed 2 years ago

chriscoey commented 2 years ago

The MWE below triggers the same error that has been causing Hypatia's tests to fail (see https://github.com/chriscoey/Hypatia.jl/runs/3599357717). The issue started a month ago and was unrelated to any changes in Hypatia, so I guess something changed somewhere in MP/DP/PolyJuMP etc.

using DynamicPolynomials
@polyvar x
@polyvar y
m = monomials(vcat(x, y), 0:2)
p = rand(length(m))' * m
p2 = subs(p, y => 0.0)

julia> p2(0.5)

ERROR: ArgumentError: args must be equal in length
Stacktrace:
 [1] pairzip(#unused#::Tuple{PolyVar{true}}, #unused#::Tuple{})
   @ MultivariatePolynomials ~/.julia/packages/MultivariatePolynomials/vqcb5/src/zip.jl:9
 [2] pairzip(t::Tuple{PolyVar{true}, PolyVar{true}}, u::Tuple{Float64})
   @ MultivariatePolynomials ~/.julia/packages/MultivariatePolynomials/vqcb5/src/zip.jl:10
 [3] pairzip(p::Pair{Vector{PolyVar{true}}, Tuple{Float64}})
   @ MultivariatePolynomials ~/.julia/packages/MultivariatePolynomials/vqcb5/src/zip.jl:13
 [4] substitute
   @ ~/.julia/packages/MultivariatePolynomials/vqcb5/src/substitution.jl:31 [inlined]
 [5] (::Polynomial{true, Float64})(x::Float64)
   @ DynamicPolynomials ~/.julia/packages/DynamicPolynomials/zw67w/src/subs.jl:122
 [6] top-level scope
   @ REPL[9]:1
chriscoey commented 2 years ago

I edited the MWE above.

I suppose the issue is that variables(p2) gives both x and y, though I expected y to disappear during substitution.