Skip to content

Commit b892def

Browse files
authored
Merge pull request #225 from JuliaDiff/ox/trt
Tidy rand_tangent file
2 parents 459b8a2 + ebc9f67 commit b892def

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/rand_tangent.jl

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ Rather it is an arbitary value, that is generated using the `rng`.
77
"""
88
rand_tangent(x) = rand_tangent(Random.GLOBAL_RNG, x)
99

10-
rand_tangent(rng::AbstractRNG, x::Symbol) = NoTangent()
11-
rand_tangent(rng::AbstractRNG, x::AbstractChar) = NoTangent()
12-
rand_tangent(rng::AbstractRNG, x::AbstractString) = NoTangent()
13-
14-
rand_tangent(rng::AbstractRNG, x::Integer) = NoTangent()
15-
1610
# Try and make nice numbers with short decimal representations for good error messages
1711
# while also not biasing the sample space too much
1812
function rand_tangent(rng::AbstractRNG, x::T) where {T<:Number}
@@ -24,12 +18,10 @@ function rand_tangent(rng::AbstractRNG, x::ComplexF64)
2418
return ComplexF64(rand(rng, -9:0.1:9), rand(rng, -9:0.1:9))
2519
end
2620

27-
#BigFloat/MPFR is finicky about short numbers, this doesn't always work as well as it should
28-
21+
# BigFloat/MPFR is finicky about short numbers, this doesn't always work as well as it should
2922
# multiply by 9 to give a bigger range of values tested: no so tightly clustered around 0.
3023
rand_tangent(rng::AbstractRNG, ::BigFloat) = round(big(9 * randn(rng)), digits=5, base=2)
3124

32-
3325
rand_tangent(rng::AbstractRNG, x::Array{<:Any, 0}) = _compress_notangent(fill(rand_tangent(rng, x[])))
3426
rand_tangent(rng::AbstractRNG, x::Array) = _compress_notangent(rand_tangent.(Ref(rng), x))
3527

@@ -65,5 +57,9 @@ function rand_tangent(rng::AbstractRNG, x::T) where {T}
6557
end
6658
end
6759

60+
rand_tangent(rng::AbstractRNG, x::Symbol) = NoTangent()
61+
rand_tangent(rng::AbstractRNG, x::AbstractChar) = NoTangent()
62+
rand_tangent(rng::AbstractRNG, x::AbstractString) = NoTangent()
63+
rand_tangent(rng::AbstractRNG, x::Integer) = NoTangent()
6864
rand_tangent(rng::AbstractRNG, ::Type) = NoTangent()
6965
rand_tangent(rng::AbstractRNG, ::Module) = NoTangent()

0 commit comments

Comments
 (0)