Skip to content

Commit

Permalink
Revert "Revert "Add rand_tangent for types (#172)""
Browse files Browse the repository at this point in the history
This reverts commit 65ab55c.
  • Loading branch information
Miha Zgubic committed Jun 9, 2021
1 parent 65ab55c commit 69ccf50
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "FiniteDifferences"
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
version = "0.12.11"
version = "0.12.12"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
3 changes: 3 additions & 0 deletions src/rand_tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,6 @@ function rand_tangent(rng::AbstractRNG, x::T) where {T}
Tangent{T}(; NamedTuple{field_names}(tangents)...)
end
end

rand_tangent(rng::AbstractRNG, ::Type) = NoTangent()
rand_tangent(rng::AbstractRNG, ::Module) = NoTangent()
9 changes: 9 additions & 0 deletions test/rand_tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ using FiniteDifferences: rand_tangent
(:a, NoTangent),
(true, NoTangent),
(4, NoTangent),
(FiniteDifferences, NoTangent), # Module object
# Types (not instances of type)
(Foo, NoTangent),
(Union{Int, Foo}, NoTangent),
(Union{Int, Foo}, NoTangent),
(Vector, NoTangent),
(Vector{Float64}, NoTangent),
(Integer, NoTangent),
(Type{<:Real}, NoTangent),

# Numbers.
(5.0, Float64),
Expand Down

0 comments on commit 69ccf50

Please sign in to comment.