Skip to content

Commit

Permalink
Merge branch 'JuliaSymbolics:master' into multivar_stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
n0rbed authored Aug 30, 2024
2 parents 3cc5fd0 + db877fb commit 471389f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Symbolics"
uuid = "0c5d862f-8b57-4792-8d23-62f2024744c7"
authors = ["Shashi Gowda <[email protected]>"]
version = "6.3.0"
version = "6.4.0"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down Expand Up @@ -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"
Expand Down
19 changes: 19 additions & 0 deletions ext/SymbolicsForwardDiffExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
###################################
Expand Down
7 changes: 7 additions & 0 deletions test/forwarddiff_symbolic_dual_ops.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 z
y(x) = isequal(z, x) ? 0 : x
@test ForwardDiff.derivative(y, 0) == 1 # expect ∂(x)/∂x
end
10 changes: 5 additions & 5 deletions test/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 471389f

Please sign in to comment.