From c52ac88e27c4fbe2fc26d5583f907c494032736b Mon Sep 17 00:00:00 2001 From: Nicholas Bauer Date: Tue, 17 Sep 2024 09:55:45 -0400 Subject: [PATCH] Make NoTangent have an eltype of itself. --- src/tangent_types/abstract_zero.jl | 2 ++ test/tangent_types/abstract_zero.jl | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/tangent_types/abstract_zero.jl b/src/tangent_types/abstract_zero.jl index 6838168af..c5260489e 100644 --- a/src/tangent_types/abstract_zero.jl +++ b/src/tangent_types/abstract_zero.jl @@ -93,6 +93,8 @@ end """ struct NoTangent <: AbstractZero end +Base.eltype(::Type{NoTangent}) = NoTangent + """ zero_tangent(primal) diff --git a/test/tangent_types/abstract_zero.jl b/test/tangent_types/abstract_zero.jl index 94df8e2ac..85a9e1d07 100644 --- a/test/tangent_types/abstract_zero.jl +++ b/test/tangent_types/abstract_zero.jl @@ -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