Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "comment out trinary rules" #62

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "DiffRules"
uuid = "b552c78f-8df3-52c6-915a-8e097449b14b"
version = "1.3.1"
version = "1.4.0"

[deps]
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
Expand Down
6 changes: 1 addition & 5 deletions src/rules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,10 @@ end
# trinary #
#---------#

#=

@define_diffrule Base.muladd(x, y, z) = :($y), :($x), :(one($z))
@define_diffrule Base.fma(x, y, z) = :($y), :($x), :(one($z))

@define_diffrule Base.ifelse(p, x, y) = false, :($p), :(!$p)

=#
@define_diffrule Base.ifelse(p, x, y) = NaN, :($p), :(!$p)

####################
# SpecialFunctions #
Expand Down
8 changes: 3 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ for (M, f, arity) in DiffRules.diffrules()
end
end
elseif arity == 3
#=
@test DiffRules.hasdiffrule(M, f, 3)
derivs = DiffRules.diffrule(M, f, :foo, :bar, :goo)
@eval begin
Expand All @@ -63,7 +62,6 @@ for (M, f, arity) in DiffRules.diffrules()
@test isapprox(dz, finitediff(z -> $M.$f(foo, bar, z), goo), rtol=0.05)
end
end
=#
end
end

Expand All @@ -82,16 +80,16 @@ for xtype in [:Float64, :BigFloat, :Int64]
end

# Test ifelse separately as first argument is boolean
#=
@test DiffRules.hasdiffrule(:Base, :ifelse, 3)
derivs = DiffRules.diffrule(:Base, :ifelse, :foo, :bar, :goo)
for cond in [true, false]
for cond in (true, false)
@eval begin
foo = $cond
bar, gee = randn(2)
dx, dy, dz = $(derivs[1]), $(derivs[2]), $(derivs[3])
@test isapprox(dy, finitediff(y -> ifelse(foo, y, goo), bar), rtol=0.05)
@test isapprox(dz, finitediff(z -> ifelse(foo, bar, z), goo), rtol=0.05)
mcabbott marked this conversation as resolved.
Show resolved Hide resolved
@test isnan(dx)
end
end
=#