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

RFC: added method for quantile(v::AbstractArray, ...) #31026

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stdlib/Statistics/src/Statistics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ quantile(itr, p; sorted::Bool=false) = quantile!(collect(itr), p, sorted=sorted)
quantile(v::AbstractVector, p; sorted::Bool=false) =
quantile!(sorted ? v : Base.copymutable(v), p; sorted=sorted)

quantile(v::AbstractArray, p; sorted::Bool=false) = quantile(vec(v), p; sorted=sorted)

##### SparseArrays optimizations #####

Expand Down
1 change: 1 addition & 0 deletions stdlib/Statistics/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ end
@test quantile([1, 2, 3, 4], (0.5,)) == (2.5,)
@test quantile([4, 9, 1, 5, 7, 8, 2, 3, 5, 17, 11], (0.1, 0.2, 0.4, 0.9)) == (2.0, 3.0, 5.0, 11.0)
@test quantile([1, 2, 3, 4], ()) == ()
@test quantile([1 2; 3 4],0.5) == 2.5

@test_throws ArgumentError quantile([1, missing], 0.5)
@test_throws ArgumentError quantile([1, NaN], 0.5)
Expand Down