Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pairwise does not work for corkendall or corspearman #846

Closed
PGS62 opened this issue Jan 9, 2023 · 1 comment
Closed

pairwise does not work for corkendall or corspearman #846

PGS62 opened this issue Jan 9, 2023 · 1 comment

Comments

@PGS62
Copy link
Contributor

PGS62 commented Jan 9, 2023

Currently pairwise works with cor but not with corkendall or corspearman

I think the fix is straightforward: Change the type declarations for each method of corkendall and corspearman to be AbstractVector in place of AbstractVector{<:Real} and AbstractMatrix in place of AbstractMatrix{<:Real}.

If I made a PR for that would it be likely to be merged?

julia> x = [1 2;3 4;5 missing]
3×2 Matrix{Union{Missing, Int64}}:
 1  2
 3  4
 5   missing

julia> pairwise(cor,eachcol(x),skipmissing=:pairwise)
2×2 Matrix{Float64}:
 1.0  1.0
 1.0  1.0

julia> pairwise(corkendall,eachcol(x),skipmissing=:pairwise)
ERROR: MethodError: no method matching corkendall(::SubArray{Union{Missing, Int64}, 1, Matrix{Union{Missing, Int64}}, Tuple{Vector{Int64}, Int64}, false}, ::SubArray{Union{Missing, Int64}, 1, Matrix{Union{Missing, Int64}}, Tuple{Vector{Int64}, Int64}, false})
Stacktrace:
 [1] _pairwise!(#unused#::Val{:pairwise}, f::typeof(corkendall), dest::Matrix{Float64}, x::Vector{SubArray{Union{Missing, Int64}, 1, Matrix{Union{Missing, Int64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}, y::Vector{SubArray{Union{Missing, Int64}, 1, Matrix{Union{Missing, Int64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}, symmetric::Bool)
   @ StatsBase C:\Users\phili\.julia\packages\StatsBase\XgjIN\src\pairwise.jl:63
 [2] _pairwise!(f::Function, dest::Matrix{Float64}, x::Vector{SubArray{Union{Missing, Int64}, 1, Matrix{Union{Missing, Int64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}, y::Vector{SubArray{Union{Missing, Int64}, 1, Matrix{Union{Missing, Int64}}, Tuple{Base.Slice{Base.OneTo{Int64}}, Int64}, true}}; symmetric::Bool, skipmissing::Symbol)
   @ StatsBase C:\Users\phili\.julia\packages\StatsBase\XgjIN\src\pairwise.jl:121
 [3] _pairwise(#unused#::Val{:pairwise}, f::typeof(corkendall), x::Base.Generator{Base.OneTo{Int64}, Base.var"#242#243"{Matrix{Union{Missing, Int64}}}}, y::Base.Generator{Base.OneTo{Int64}, Base.var"#242#243"{Matrix{Union{Missing, Int64}}}}, symmetric::Bool)
   @ StatsBase C:\Users\phili\.julia\packages\StatsBase\XgjIN\src\pairwise.jl:172
 [4] pairwise(f::Function, x::Base.Generator{Base.OneTo{Int64}, Base.var"#242#243"{Matrix{Union{Missing, Int64}}}}, y::Base.Generator{Base.OneTo{Int64}, Base.var"#242#243"{Matrix{Union{Missing, Int64}}}}; symmetric::Bool, skipmissing::Symbol)
   @ StatsBase C:\Users\phili\.julia\packages\StatsBase\XgjIN\src\pairwise.jl:315
 [5] top-level scope
   @ REPL[17]:1
@PGS62 PGS62 closed this as completed Feb 16, 2023
@PGS62 PGS62 reopened this Feb 16, 2023
@PGS62
Copy link
Contributor Author

PGS62 commented Feb 27, 2023

Closing because I think the solution proposed is not a good one. Better to change pairwise so that it calls f passing in x and y of type AbstractVector{<:Real}.

@PGS62 PGS62 closed this as completed Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant