Skip to content

Commit

Permalink
Add rand_tangent for types (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
mzgubic authored Jun 8, 2021
1 parent 3ddcb0d commit 91d6652
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

2 comments on commit 91d6652

@mzgubic
Copy link
Member Author

@mzgubic mzgubic commented on 91d6652 Jun 8, 2021

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/38406

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.12.12 -m "<description of version>" 91d6652b96ee43f9610151def2039999a0591601
git push origin v0.12.12

Please sign in to comment.