-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Improve quantile in corner cases of collection eltype #30938
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
Changes from 3 commits
25d7277
dd08824
64fac8d
00de656
e75d6e4
09b7eaf
b7105fb
d1e9b7e
25909a5
94b164b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -821,8 +821,11 @@ function quantile!(q::AbstractArray, v::AbstractVector, p::AbstractArray; | |
return q | ||
end | ||
|
||
quantile!(v::AbstractVector, p::AbstractArray; sorted::Bool=false) = | ||
quantile!(similar(p,float(eltype(v))), v, p; sorted=sorted) | ||
function quantile!(v::AbstractVector, p::AbstractArray; sorted::Bool=false) | ||
T = Core.Compiler.typesubtract(eltype(v), Missing) | ||
S = T <: AbstractFloat ? T : promote_type(T, Float64) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason not to use the same approach as method below which is used when There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. Fixed. |
||
quantile!(similar(p, S), v, p; sorted=sorted) | ||
end | ||
|
||
quantile!(v::AbstractVector, p::Real; sorted::Bool=false) = | ||
_quantile(_quantilesort!(v, sorted, p, p), p) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually can't we just use this method for tuple
p
?map
should do the right thing in both cases.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right - I will merge them.