Skip to content

RealFP types too restrictive for signalcorr.jl methods #459

Closed
@danmackinlay

Description

@danmackinlay

the methods in signcorr.jl require arrays of RealFP types;
This seems to me to be too restrictive since it, for example, the Dual types used by ForwardDiff.jl, and prevents differentiating through these functions.

Does anyone know a reason that we have this restriction? If I can get some clues about the reasons for this design choice I can propose a patch.

julia> using StatsBase:  autocov
julia> using ForwardDiff
julia> f2(x::Vector) = autocov(x, [0])[1]
julia> g2 = x -> ForwardDiff.gradient(f2, x);
julia> f2([1.0]), g2([1.0])

MethodError: no method matching fptype(::Type{ForwardDiff.Dual{ForwardDiff.Tag{typeof(f2),Float64},Float64,1}})
Closest candidates are:
  fptype(!Matched::Type{Complex{Float32}}) at /home/dan/.julia/packages/StatsBase/yNoh6/src/common.jl:27
  fptype(!Matched::Type{Complex{Float64}}) at /home/dan/.julia/packages/StatsBase/yNoh6/src/common.jl:28
  fptype(!Matched::Type{T<:Union{Bool, Float32, Int16, Int8, UInt16, UInt8}}) where T<:Union{Bool, Float32, Int16, Int8, UInt16, UInt8} at /home/dan/.julia/packages/StatsBase/yNoh6/src/common.jl:25
  ...

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