Skip to content

rand_tangent and zero-arrays.  #179

@AlexRobson

Description

@AlexRobson

Bit of an edge case but:

using Test
using FiniteDifferences

x = rand(2,2)
@test typeof(rand_tangent(x)) == typeof(x) # Passes
x = rand(1,)
@test typeof(rand_tangent(x)) == typeof(x) # Passes
x = fill(rand())
@test typeof(rand_tangent(x)) == typeof(x) # Fails

idk how often this will come up, but in the case that x is a zero-array, presently rand_tangent will change it from Array{T, 0} to T. It came up when testing some test_rrules with zero-arrays.

I think defining rand_tangent(rng::AbstractRNG, x::StridedArray{T, 0}) where {T} would be sufficient here? So simple to fix, if it's wanted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions