From 47ac48d83b7197b204b61b36346df11f68d5f164 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 28 Aug 2024 07:05:10 -0400 Subject: [PATCH 1/6] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index acf3e459b..5e02b13ee 100644 --- a/Project.toml +++ b/Project.toml @@ -68,7 +68,7 @@ DiffRules = "1.4" Distributions = "0.25" DocStringExtensions = "0.9" DomainSets = "0.6, 0.7" -DynamicPolynomials = "0.6" +DynamicPolynomials = "0.5, 0.6" ForwardDiff = "0.10.36" Groebner = "0.5, 0.6, 0.7" IfElse = "0.1" From 389a4cdf0c920e8da90065255cbdd961aec251e1 Mon Sep 17 00:00:00 2001 From: Christopher Rackauckas Date: Wed, 28 Aug 2024 07:05:18 -0400 Subject: [PATCH 2/6] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 5e02b13ee..e893e2fbd 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "Symbolics" uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7" authors = ["Shashi Gowda "] -version = "6.3.0" +version = "6.4.0" [deps] ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b" From 60b8fc6e1557e8e92d109bdf8230eabaa0cb946d Mon Sep 17 00:00:00 2001 From: Daniel VandenHeuvel <95613936+DanielVandH@users.noreply.github.com> Date: Wed, 28 Aug 2024 13:13:10 +0100 Subject: [PATCH 3/6] Add missing at test --- test/utils.jl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/utils.jl b/test/utils.jl index c601f653b..5121a0300 100644 --- a/test/utils.jl +++ b/test/utils.jl @@ -23,9 +23,9 @@ end @testset "symbolic_to_float" begin @variables x - symbolic_to_float((1//2 * x)/x) isa Float64 - symbolic_to_float((1/2 * x)/x) isa Float64 - symbolic_to_float((1//2)*√(279//4)) isa Float64 - symbolic_to_float((big(1)//2)*√(279//4)) isa BigFloat - symbolic_to_float((-1//2)*√(279//4)) isa Float64 + @test symbolic_to_float((1//2 * x)/x) isa Rational{Int} + @test symbolic_to_float((1/2 * x)/x) isa Float64 + @test symbolic_to_float((1//2)*√(279//4)) isa Float64 + @test symbolic_to_float((big(1)//2)*√(279//4)) isa BigFloat + @test symbolic_to_float((-1//2)*√(279//4)) isa Float64 end From e0bde4a08a5253c90d7e142b07724273908d008d Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Thu, 29 Aug 2024 11:46:55 +0200 Subject: [PATCH 4/6] Resolve isequal(Num, ForwardDiff.Dual) ambiguity --- ext/SymbolicsForwardDiffExt.jl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/ext/SymbolicsForwardDiffExt.jl b/ext/SymbolicsForwardDiffExt.jl index 480fc83f5..9882bec12 100644 --- a/ext/SymbolicsForwardDiffExt.jl +++ b/ext/SymbolicsForwardDiffExt.jl @@ -103,6 +103,25 @@ function binary_dual_definition(M, f, Ts) return expr end +##################### +# Generic Functions # +##################### + +# Predicates # +#------------# + +for pred in [:isequal, :(==)] + @eval begin + @define_binary_dual_op( + Base.$(pred), + $(pred)(value(x), value(y)) && $(pred)(partials(x), partials(y)), + $(pred)(value(x), y) && iszero(partials(x)), + $(pred)(x, value(y)) && iszero(partials(y)), + $AMBIGUOUS_TYPES + ) + end +end + ################################### # General Mathematical Operations # ################################### From 3664e2091dd369c99dd7f4550cbe4d4744da4dd3 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Thu, 29 Aug 2024 12:03:30 +0200 Subject: [PATCH 5/6] Test isequal(Num, ForwardDiff.Dual) ambiguity --- test/forwarddiff_symbolic_dual_ops.jl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/forwarddiff_symbolic_dual_ops.jl b/test/forwarddiff_symbolic_dual_ops.jl index 1b89c79e6..d5e3d3f47 100644 --- a/test/forwarddiff_symbolic_dual_ops.jl +++ b/test/forwarddiff_symbolic_dual_ops.jl @@ -107,3 +107,10 @@ for f ∈ (hypot, muladd) end # fma is not defined for Symbolics.Num + +# https://github.com/JuliaSymbolics/Symbolics.jl/issues/1246 +@testset "isequal type ambiguity" begin + @variables x + xfunc(xval) = isequal(x, xval) ? xval : xval + @test ForwardDiff.derivative(xfunc, 0.0) == 1.0 +end From f0bcc47f9411b7d5aed72cd85db679b4557bc488 Mon Sep 17 00:00:00 2001 From: Herman Sletmoen Date: Thu, 29 Aug 2024 15:43:08 +0200 Subject: [PATCH 6/6] Improve test --- test/forwarddiff_symbolic_dual_ops.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/forwarddiff_symbolic_dual_ops.jl b/test/forwarddiff_symbolic_dual_ops.jl index d5e3d3f47..e132f9a50 100644 --- a/test/forwarddiff_symbolic_dual_ops.jl +++ b/test/forwarddiff_symbolic_dual_ops.jl @@ -110,7 +110,7 @@ end # https://github.com/JuliaSymbolics/Symbolics.jl/issues/1246 @testset "isequal type ambiguity" begin - @variables x - xfunc(xval) = isequal(x, xval) ? xval : xval - @test ForwardDiff.derivative(xfunc, 0.0) == 1.0 + @variables z + y(x) = isequal(z, x) ? 0 : x + @test ForwardDiff.derivative(y, 0) == 1 # expect ∂(x)/∂x end