From e5d04feabd62b8e32dd52f2ad59867c9e960e94d Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 5 Dec 2024 16:25:59 +0000 Subject: [PATCH 1/3] Fix #166 --- Project.toml | 2 +- src/promote.jl | 6 ++++++ test/runtests.jl | 6 ++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 02c7d93..bab71f2 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "DynamicPolynomials" uuid = "7c1d4256-1411-5781-91ec-d7bc3513ac07" repo = "https://github.com/JuliaAlgebra/DynamicPolynomials.jl.git" -version = "0.6.1" +version = "0.6.2" [deps] Future = "9fa8497b-333b-5362-9e8d-4d0656e87820" diff --git a/src/promote.jl b/src/promote.jl index 05eb398..9aa63be 100644 --- a/src/promote.jl +++ b/src/promote.jl @@ -1,3 +1,9 @@ +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{<:DMonomialLike{V,M}}, +) where {V,M} + return Any +end function MP.promote_rule_constant( ::Type{T}, ::Type{<:DMonomialLike{V,M}}, diff --git a/test/runtests.jl b/test/runtests.jl index ac0c6e0..e1822cc 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -82,4 +82,10 @@ import DynamicPolynomials end end +@testset "Issue #166: promote_operation with Any" begin + DynamicPolynomials.@polyvar x + V = typeof(x) + @test promote_type(V, Any) == Any +end + include("mvp.jl") From 46a07af29024539412821cc903213cad61975201 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 7 Dec 2024 08:28:27 +0000 Subject: [PATCH 2/3] Overload other promote cases --- src/promote.jl | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/promote.jl b/src/promote.jl index 9aa63be..0e697a7 100644 --- a/src/promote.jl +++ b/src/promote.jl @@ -4,6 +4,24 @@ function MP.promote_rule_constant( ) where {V,M} return Any end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{_Term{V,M,T}}, +) where {V,M,T} + return Any +end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{_Term{V,M,T}}, +) where {V,M,T} + return Any +end +function MP.promote_rule_constant( + ::Type{Any}, + ::Type{<:TermPoly{V,M,T}}, +) where {V,M,T} + return Any +end function MP.promote_rule_constant( ::Type{T}, ::Type{<:DMonomialLike{V,M}}, From fca9e3e0cd485a2518e8c4ff259e9f39ef591965 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Sat, 7 Dec 2024 08:29:24 +0000 Subject: [PATCH 3/3] Update runtests.jl --- test/runtests.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/runtests.jl b/test/runtests.jl index e1822cc..e96867d 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -86,6 +86,7 @@ end DynamicPolynomials.@polyvar x V = typeof(x) @test promote_type(V, Any) == Any + @test promote_type(typeof(x/2), Any) == Any end include("mvp.jl")