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

Failed type assertion in pairwise #771

Closed
yha opened this issue Feb 27, 2022 · 1 comment · Fixed by #772
Closed

Failed type assertion in pairwise #771

yha opened this issue Feb 27, 2022 · 1 comment · Fixed by #772

Comments

@yha
Copy link
Contributor

yha commented Feb 27, 2022

using HypothesisTests, StatsBase
function test(x)
	pairwise(eachindex(x); symmetric=true) do j,i
		pval = pvalue(SignedRankTest(x[i], x[j]))
		pval, rand()
	end
end

x = [rand(1000) for _=1:10]

test(x)
ERROR: TypeError: in typeassert, expected Matrix{<:Tuple{Union{Nothing, Float64, Int64}, Float64}}, got a value of type Matrix{Tuple{Real, Float64}}
Stacktrace:
 [1] _pairwise(#unused#::Val{:none}, f::var"#29#30"{Vector{Vector{Float64}}}, x::Base.OneTo{Int64}, y::Base.OneTo{Int64}, symmetric::Bool)
   @ StatsBase C:\Users\sternlab\.julia\packages\StatsBase\pJqvO\src\pairwise.jl:155
 [2] pairwise(f::Function, x::Base.OneTo{Int64}, y::Base.OneTo{Int64}; symmetric::Bool, skipmissing::Symbol)
   @ StatsBase C:\Users\sternlab\.julia\packages\StatsBase\pJqvO\src\pairwise.jl:288
 [3] test(x::Vector{Vector{Float64}})
   @ Main .\Untitled-9:3
 [4] top-level scope
   @ Untitled-9:11

Package versions:

  [09f84164] HypothesisTests v0.10.6
  [2913bbd2] StatsBase v0.33.16

(this doesn't happen if the pairwise call is in global scope rather than a function)

@nalimilan
Copy link
Member

Good catch. This is a very tricky case indeed. #772 fixes this. The fact that inference gives such an imprecise type in the first place could also be improved in HypothesisTests, see JuliaStats/HypothesisTests.jl#263.

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

Successfully merging a pull request may close this issue.

2 participants