Skip to content

Commit 4d30c43

Browse files
authored
Merge pull request #180 from JuliaDiff/ar/rand_tangent_zeroarrays
Rand tangent zero-dimensional arrays
2 parents 35f18b9 + 260f5da commit 4d30c43

3 files changed

Lines changed: 4 additions & 1 deletion

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "FiniteDifferences"
22
uuid = "26cc04aa-876d-5657-8c51-4c34ba976000"
3-
version = "0.12.13"
3+
version = "0.12.14"
44

55
[deps]
66
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/rand_tangent.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ end
2929
# multiply by 9 to give a bigger range of values tested: no so tightly clustered around 0.
3030
rand_tangent(rng::AbstractRNG, ::BigFloat) = round(big(9 * randn(rng)), sigdigits=5, base=2)
3131

32+
rand_tangent(rng::AbstractRNG, x::StridedArray{T, 0}) where {T} = fill(rand_tangent(x[1]))
3233
rand_tangent(rng::AbstractRNG, x::StridedArray) = rand_tangent.(Ref(rng), x)
3334
rand_tangent(rng::AbstractRNG, x::Adjoint) = adjoint(rand_tangent(rng, parent(x)))
3435
rand_tangent(rng::AbstractRNG, x::Transpose) = transpose(rand_tangent(rng, parent(x)))

test/rand_tangent.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ using FiniteDifferences: rand_tangent
2727
(big(5.0), BigFloat),
2828

2929
# StridedArrays.
30+
(fill(randn(Float32)), Array{Float32, 0}),
31+
(fill(randn(Float64)), Array{Float64, 0}),
3032
(randn(Float32, 3), Vector{Float32}),
3133
(randn(Complex{Float64}, 2), Vector{Complex{Float64}}),
3234
(randn(5, 4), Matrix{Float64}),

0 commit comments

Comments
 (0)