-
Notifications
You must be signed in to change notification settings - Fork 197
Open
Description
The quantile function with unitful quantities works fine without weights:
julia> x = rand(10) .* 1u"m"
10-element Vector{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}:
0.4560455822873759 m
0.4307569757744304 m
0.4840857672199611 m
0.7853776015820557 m
0.5865440640498318 m
0.15996668178343565 m
0.042204899384880146 m
0.3310111766347721 m
0.8691765138294111 m
0.5325561348479884 m
julia> quantile(x, 0.5)
0.4700656747536685 mHowever, if we try to pass weights, it crashes:
julia> quantile(x, Weights(1:10), 0.5)
ERROR: MethodError: no method matching quantile(::Vector{Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}}}, ::Weights{Int64, Int64, UnitRange{Int64}}, ::Float64)
Closest candidates are:
quantile(::AbstractVector{T} where T<:Real, ::AbstractWeights{var"#s42", T} where {var"#s42"<:Real, T<:Real}, ::Number)
@ StatsBase ~/.julia/packages/StatsBase/XgjIN/src/weights.jl:772
quantile(::AbstractVector{V}, ::AbstractWeights{W, T} where T<:Real, ::AbstractVector{T} where T<:Real) where {V, W<:Real}
@ StatsBase ~/.julia/packages/StatsBase/XgjIN/src/weights.jl:700
quantile(::AbstractVector, ::Any; sorted, alpha, beta)
@ Statistics ~/.julia/juliaup/julia-1.9.2+0.x64.linux.gnu/share/julia/stdlib/v1.9/Statistics/src/Statistics.jl:1073
...
Stacktrace:
[1] top-level scope
@ REPL[15]:1This method definition is too restrictive:
Line 707 in 8696d51
| function quantile(v::AbstractVector{<:Real}{V}, w::AbstractWeights{W}, p::AbstractVector{<:Real}) where {V,W<:Real} |
Metadata
Metadata
Assignees
Labels
No labels