From 486ee7abc973b1392cc6498544c782872a22e1c1 Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Sat, 25 Feb 2017 11:29:55 +0100 Subject: [PATCH] Improve docstrings for unique() Fix the signature of the AbstractArray method, add a mention of isequal() and of ordering, and use imperative form. --- base/multidimensional.jl | 11 +++++++---- base/set.jl | 5 +++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/base/multidimensional.jl b/base/multidimensional.jl index e85400ebd355a..fb50624abe322 100644 --- a/base/multidimensional.jl +++ b/base/multidimensional.jl @@ -1302,11 +1302,14 @@ end hash(x::Prehashed) = x.hash """ - unique(itr[, dim]) + unique(A::AbstractArray[, dim::Int]) + +Return an array containing only the unique elements of `A`, as determined by +[`isequal`](@ref), in the order that the first of each set of equivalent elements +originally appears. + +If `dim` is specified, return unique regions of `A` along dimension `dim`. -Returns an array containing only the unique elements of the iterable `itr`, in -the order that the first of each set of equivalent elements originally appears. -If `dim` is specified, returns unique regions of the array `itr` along `dim`. ```jldoctest julia> A = map(isodd, reshape(collect(1:8), (2,2,2))) diff --git a/base/set.jl b/base/set.jl index 38665b5f55d94..0d19af6e20437 100644 --- a/base/set.jl +++ b/base/set.jl @@ -123,8 +123,9 @@ const ⊆ = issubset """ unique(itr) -Returns an array containing one value from `itr` for each unique value, -as determined by [`isequal`](@ref). +Return an array containing only the unique elements of collection `itr`, +as determined by [`isequal`](@ref), in the order that the first of each +set of equivalent elements originally appears. ```jldoctest julia> unique([1; 2; 2; 6])