Skip to content

Commit 730ea67

Browse files
committed
define equality for CRC.ZeroTangent
1 parent 6c877da commit 730ea67

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/extra_rules.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,3 +287,8 @@ function ChainRulesCore.frule((_, ȯbj, _, ẋ), ::typeof(setproperty!), obj::M
287287
= setproperty!(ȯbj, field, ẋ)
288288
return y, ẏ
289289
end
290+
291+
# https://github.com/JuliaDiff/ChainRulesCore.jl/issues/607
292+
Base.:(==)(x::Number, ::ZeroTangent) = iszero(x)
293+
Base.:(==)(::ZeroTangent, x::Number) = iszero(x)
294+
Base.hash(x::ZeroTangent, h::UInt64) = hash(0, h)

src/stage1/forward.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function shuffle_up(r::TaylorBundle{1, Tuple{B1,B2}}) where {B1,B2}
4040
z₂ = primal(r)[2]
4141
z₁₂ = partial(r, 1)[2]
4242
if true
43-
@assert z== z₂
43+
@assert(z₁ == z₂, "$z == $z₂")
4444
return TaylorBundle{2}(z₀, (z₁, z₁₂))
4545
else
4646
return ExplicitTangentBundle{2}(z₀, (z₁, z₂, z₁₂))

0 commit comments

Comments
 (0)