From dd5eba0ea704a8d0e51583578545fc9861d77a16 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Tue, 19 Aug 2025 13:19:07 +0530 Subject: [PATCH 1/3] fix: handle non-concrete polynomials in `polynomial_merge!` --- src/operators.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/operators.jl b/src/operators.jl index a0b8d033..fa8f55cc 100644 --- a/src/operators.jl +++ b/src/operators.jl @@ -91,7 +91,9 @@ function polynomial_merge!( combine::F6, keep::F7, resize::F8, -) where {F1,F2,F3,F4,F5,F6,F7,F8} + ::Type{term_type} = n1 > 0 ? typeof(get1(1)) : + n2 > 0 ? typeof(get2(1)) : Nothing, +) where {F1,F2,F3,F4,F5,F6,F7,F8,term_type} buffer = nothing i = j = k = 1 # Invariant: @@ -109,7 +111,7 @@ function polynomial_merge!( if k == i t0 = get1(i) if buffer === nothing - buffer = DataStructures.Queue{typeof(t0)}() + buffer = DataStructures.Queue{term_type}() end push!(buffer, t0) i += 1 From 3dd6a05c4490798cf83f9223de3da3b20168c154 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 17 Sep 2025 17:23:16 +0530 Subject: [PATCH 2/3] test: mark test as no longer broken --- test/commutative/complex.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/commutative/complex.jl b/test/commutative/complex.jl index a69e4b61..2765822b 100644 --- a/test/commutative/complex.jl +++ b/test/commutative/complex.jl @@ -6,7 +6,7 @@ @test !isconj(a) @test ordinary_variable(a) == a @test conj(a) == real(a) == a - @test_broken iszero(imag(a)) # no iszero for MA.Zero + @test iszero(imag(a)) @test isreal(a^3 + 5a^2 + 4a) @test !isreal(a^3 + 5im * a^2 + 4a) From 3e666441e9346873fdb4d419ac90fbd000c21c80 Mon Sep 17 00:00:00 2001 From: Aayush Sabharwal Date: Wed, 17 Sep 2025 18:31:30 +0530 Subject: [PATCH 3/3] test: run non-concrete polynomial GCD test only for DynamicPolynomials --- test/commutative/gcd.jl | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/test/commutative/gcd.jl b/test/commutative/gcd.jl index c5c43a00..fe7c043a 100644 --- a/test/commutative/gcd.jl +++ b/test/commutative/gcd.jl @@ -291,14 +291,15 @@ end end end end - @testset "Non-concrete polynomial GCD" begin - Mod.@polyvar p q - p1 = MP.polynomial(p^2 + q^2, Number) - p2 = MP.polynomial(p * q, Number) - g = @inferred gcd(p1, p2) - @test isone(g) + if nameof(Mod) == :DynamicPolynomials + @testset "Non-concrete polynomial GCD" begin + Mod.@polyvar p q + p1 = MP.polynomial(p^2 + q^2, Number) + p2 = MP.polynomial(p * q, Number) + g = @inferred gcd(p1, p2) + @test isone(g) + end end - @testset "Complex coefficient GCD" begin Mod.@polyvar p q p1 = MP.polynomial(p^2 + q^2, ComplexF64)