Skip to content

Commit c52ac88

Browse files
committed
Make NoTangent have an eltype of itself.
1 parent 5369090 commit c52ac88

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/tangent_types/abstract_zero.jl

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ end
9393
"""
9494
struct NoTangent <: AbstractZero end
9595

96+
Base.eltype(::Type{NoTangent}) = NoTangent
97+
9698
"""
9799
zero_tangent(primal)
98100

test/tangent_types/abstract_zero.jl

+3
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@
119119
@test dot(dne, 17.2) == dne
120120
@test dot(11.9, dne) == dne
121121

122+
@test eltype(dne) === NoTangent
123+
@test eltype(NoTangent) === NoTangent
124+
122125
@test promote_type(NoTangent, Bool) == Bool
123126
@test promote_type(Bool, NoTangent) == Bool
124127
@test promote_type(NoTangent, Int64) == Int64

0 commit comments

Comments
 (0)