Skip to content

Commit

Permalink
Make NoTangent have an eltype of itself.
Browse files Browse the repository at this point in the history
  • Loading branch information
BioTurboNick committed Sep 17, 2024
1 parent 5369090 commit c52ac88
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/tangent_types/abstract_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ end
"""
struct NoTangent <: AbstractZero end

Base.eltype(::Type{NoTangent}) = NoTangent

"""
zero_tangent(primal)
Expand Down
3 changes: 3 additions & 0 deletions test/tangent_types/abstract_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@
@test dot(dne, 17.2) == dne
@test dot(11.9, dne) == dne

@test eltype(dne) === NoTangent
@test eltype(NoTangent) === NoTangent

@test promote_type(NoTangent, Bool) == Bool
@test promote_type(Bool, NoTangent) == Bool
@test promote_type(NoTangent, Int64) == Int64
Expand Down

0 comments on commit c52ac88

Please sign in to comment.