Skip to content

Commit

Permalink
Merge b4a0171 into f4731b7
Browse files Browse the repository at this point in the history
  • Loading branch information
oxinabox authored Feb 23, 2024
2 parents f4731b7 + b4a0171 commit 5126334
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tangent_types/abstract_zero.jl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ end
function zero_tangent(::T) where {K,V,T<:AbstractDict{K,V}}
return Tangent{T}(Dict{K,guess_zero_tangent_type(V)}())
end
if isdefined(Base, :Pairs)
zero_tangent(::Base.Pairs{Symbol,Union{},Tuple{},@NamedTuple{}}) = NoTangent()
end

# Sad heauristic methods we need because of unassigned values
guess_zero_tangent_type(::Type{T}) where {T<:Number} = T
Expand All @@ -180,6 +183,7 @@ function guess_zero_tangent_type(::Type{<:Array{T,N}}) where {T,N}
return Array{guess_zero_tangent_type(T),N}
end
guess_zero_tangent_type(T::Type) = Any
guess_zero_tangent_type(::Type{Union{}}) = Union{} # This will only show up for empty containers

# Stuff that conceptually has its own identity regardless of structual implementation and doesn't have a tangent
zero_tangent(::Base.AbstractLogger) = NoTangent()
Expand All @@ -190,4 +194,4 @@ zero_tangent(::Expr) = NoTangent()
zero_tangent(::Core.Compiler.AbstractInterpreter) = NoTangent()
zero_tangent(::Core.Compiler.InstructionStream) = NoTangent()
zero_tangent(::Core.CodeInfo) = NoTangent()
zero_tangent(::Core.MethodInstance) = NoTangent()
zero_tangent(::Core.MethodInstance) = NoTangent()

0 comments on commit 5126334

Please sign in to comment.