From 348c35129841608e16facdf7a0090b8f278035a6 Mon Sep 17 00:00:00 2001 From: Benjamin Desef Date: Mon, 13 May 2024 21:10:22 +0200 Subject: [PATCH 1/2] Update for changes discussed in https://github.com/JuliaAlgebra/DynamicPolynomials.jl/pull/121 - Macro for complex variables is now called `@complex_polyvar` - DP does not support partial substitutions, so disable the tests --- src/complex.jl | 4 +++- test/commutativetests.jl | 2 +- test/complex.jl | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/complex.jl b/src/complex.jl index 9575bc34..f0547ff4 100644 --- a/src/complex.jl +++ b/src/complex.jl @@ -186,7 +186,9 @@ for fun in [:real, :imag] iszero(x) && return zero(polynomial_type(x, real(coefficient_type(x)))) # We replace every complex variable by its decomposition into real and imaginary part - subst_vars = filter(Base.:! ∘ isreal, variables(x)) + subst_vars = unique( + ordinary_variable(v) for v in variables(x) if !isreal(v) + ) # To avoid a stack overflow on promote_type, we'll handle the empty case separately full_version = isempty(subst_vars) ? polynomial(x) : diff --git a/test/commutativetests.jl b/test/commutativetests.jl index 94b4b6a3..c4bb9d63 100644 --- a/test/commutativetests.jl +++ b/test/commutativetests.jl @@ -9,7 +9,7 @@ include("polynomial.jl") include("det.jl") include("rational.jl") -isdefined(Mod, Symbol("@polycvar")) && include("complex.jl") +isdefined(Mod, Symbol("@complex_polyvar")) && include("complex.jl") include("promote.jl") include("hash.jl") diff --git a/test/complex.jl b/test/complex.jl index 35229673..be2fb3f5 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -10,7 +10,7 @@ @test isreal(a^3 + 5a^2 + 4a) @test !isreal(a^3 + 5im * a^2 + 4a) - Mod.@polycvar x y + Mod.@complex_polyvar x y @test !isreal(x) @test !isrealpart(x) && !isrealpart(conj(x)) && @@ -73,9 +73,9 @@ @test subs(4x + 8y^2 - 6x^3, [x, y] => [2 + 4im, 9 - im]) == (1176 - 32im) * x^0 - @test subs(4x + 8y^2 - 6x^3, [x, conj(y)] => [2 + 4im, 9 - im]) == + @test_broken subs(4x + 8y^2 - 6x^3, [x, conj(y)] => [2 + 4im, 9 - im]) == (1176 + 256im) * x^0 @test_broken subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9]) - @test subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9 + 0 * x^0]) == + @test_broken subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9 + 0 * x^0]) == 1184 + 112im + 144im * imag(y) - 8imag(y)^2 end From 9d557f2177aca1992d37410af97427b8d302c6b1 Mon Sep 17 00:00:00 2001 From: Benjamin Desef Date: Tue, 14 May 2024 17:58:29 +0200 Subject: [PATCH 2/2] Add explanation, format --- test/complex.jl | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/complex.jl b/test/complex.jl index be2fb3f5..f4b22131 100644 --- a/test/complex.jl +++ b/test/complex.jl @@ -73,9 +73,13 @@ @test subs(4x + 8y^2 - 6x^3, [x, y] => [2 + 4im, 9 - im]) == (1176 - 32im) * x^0 + # the following are currently not supported by DP (substitution variables may + # only be the ordinary_variable, not a conjugate or real/imaginary part) @test_broken subs(4x + 8y^2 - 6x^3, [x, conj(y)] => [2 + 4im, 9 - im]) == - (1176 + 256im) * x^0 + (1176 + 256im) * x^0 @test_broken subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9]) - @test_broken subs(4x + 8y^2 - 6x^3, [x, real(y)] => [2 + 4im, 9 + 0 * x^0]) == - 1184 + 112im + 144im * imag(y) - 8imag(y)^2 + @test_broken subs( + 4x + 8y^2 - 6x^3, + [x, real(y)] => [2 + 4im, 9 + 0 * x^0], + ) == 1184 + 112im + 144im * imag(y) - 8imag(y)^2 end