Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rand_tangent for types #172

Merged
merged 5 commits into from
Jun 8, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is needed to work on Julia 1.0

2 changes: 2 additions & 0 deletions test/rand_tangent.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ using FiniteDifferences: rand_tangent
(:a, NoTangent),
(true, NoTangent),
(4, NoTangent),
(FiniteDifferences, NoTangent),
(Foo, NoTangent),
mzgubic marked this conversation as resolved.
Show resolved Hide resolved

# Numbers.
(5.0, Float64),
Expand Down