Skip to content

Commit 6138a11

Browse files
authored
Cleanup docs (JuliaLang#708)
Ensure that all exported methods are included in the manual, so that we can enable strict=true, which ensures that doctests pass. Update doctests to latest Julia version.
1 parent 7fcea24 commit 6138a11

14 files changed

+76
-41
lines changed

docs/make.jl

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ makedocs(
1010
modules = [StatsBase],
1111
pages = ["index.md",
1212
"weights.md",
13-
"means.md",
1413
"scalarstats.md",
1514
"robust.md",
1615
"deviation.md",
@@ -23,7 +22,9 @@ makedocs(
2322
"multivariate.md",
2423
"misc.md",
2524
"statmodels.md",
26-
"transformations.md"]
25+
"transformations.md"],
26+
strict=true,
27+
checkdocs=:exports
2728
)
2829

2930
deploydocs(

docs/src/counts.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ addcounts!(r::AbstractArray, x::StatsBase.IntegerArray, levels::StatsBase.IntUni
1515
```@docs
1616
countmap
1717
proportionmap
18-
addcounts!{T}(cm::Dict{T}, x::AbstractArray{T})
18+
addcounts!(cm::Dict, x::Any)
1919
```

docs/src/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212

1313

1414
```@contents
15-
Pages = ["weights.md", "means.md", "scalarstats.md", "robust.md", "deviation.md", "cov.md", "counts.md", "ranking.md", "sampling.md", "empirical.md", "signalcorr.md", "misc.md", "statmodels.md", "transformations.md"]
15+
Pages = ["weights.md", "scalarstats.md", "robust.md", "deviation.md", "cov.md", "counts.md", "ranking.md", "sampling.md", "empirical.md", "signalcorr.md", "misc.md", "statmodels.md", "transformations.md"]
1616
Depth = 2
1717
```
1818

docs/src/means.md

-17
This file was deleted.

docs/src/robust.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
```@docs
44
trim
5+
trim!
56
winsor
7+
winsor!
68
trimvar
79
```

docs/src/sampling.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ The package provides functions for sampling from a given population (with or wit
77
```@docs
88
sample
99
sample!
10+
wsample
11+
wsample!
1012
```
1113

1214
## Algorithms

docs/src/scalarstats.md

+22
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22

33
The package implements functions for computing various statistics over an array of scalar real numbers.
44

5+
## Weighted sum and mean
6+
7+
```@docs
8+
sum
9+
sum!
10+
wsum
11+
wsum!
12+
mean
13+
mean!
14+
```
15+
16+
## Means
17+
18+
The package provides functions to compute means of different kinds.
19+
20+
```@docs
21+
geomean
22+
harmmean
23+
genmean
24+
```
25+
526
## Moments
627

728
```@docs
@@ -21,6 +42,7 @@ span
2142
variation
2243
sem
2344
mad
45+
mad!
2446
```
2547

2648
## Z-scores

docs/src/statmodels.md

+6
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ loglikelihood
2424
mss
2525
nobs
2626
nulldeviance
27+
nullloglikelihood
2728
r2
2829
rss
2930
score
@@ -47,3 +48,8 @@ predict
4748
predict!
4849
residuals
4950
```
51+
52+
An exception type is provided to signal convergence failures during model estimation:
53+
```@docs
54+
ConvergenceException
55+
```

docs/src/transformations.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,17 @@ in a single call.
4040
fit(::Type{UnitRangeTransform}, X::AbstractArray{<:Real,2}; unit::Bool=true)
4141
```
4242

43-
## Additional Methods
43+
## Methods
4444
```@docs
4545
StatsBase.transform
4646
StatsBase.transform!
4747
StatsBase.reconstruct
4848
StatsBase.reconstruct!
4949
standardize
5050
```
51+
52+
## Types
53+
```@docs
54+
UnitRangeTransform
55+
ZScoreTransform
56+
```

docs/src/weights.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ w = uweights(Float64, 3)
5454

5555
### `Weights`
5656

57-
The `Weights` type describes a generic weights vector which does not support all operations possible for `FrequencyWeights`, `AnalyticWeights` and `ProbabilityWeights`.
57+
The `Weights` type describes a generic weights vector which does not support all operations possible for `FrequencyWeights`, `AnalyticWeights`, `ProbabilityWeights` and `UnitWeights`.
5858

5959
```julia
6060
w = Weights([1., 2., 3.])
@@ -142,10 +142,12 @@ The following constructors are provided:
142142
AnalyticWeights
143143
FrequencyWeights
144144
ProbabilityWeights
145+
UnitWeights
145146
Weights
146147
aweights
147148
fweights
148149
pweights
149150
eweights
151+
uweights
150152
weights
151153
```

src/hist.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,15 @@ Histograms can be fitted to data using the `fit` method.
137137
julia> using StatsBase
138138
139139
julia> fit(Histogram, [2.], 1:3, closed=:left)
140-
Histogram{Int64,1,Tuple{UnitRange{Int64}}}
140+
Histogram{Int64, 1, Tuple{UnitRange{Int64}}}
141141
edges:
142142
1:3
143143
weights: [0, 1]
144144
closed: left
145145
isdensity: false
146146
147147
julia> fit(Histogram, [2.], 1:3, closed=:right)
148-
Histogram{Int64,1,Tuple{UnitRange{Int64}}}
148+
Histogram{Int64, 1, Tuple{UnitRange{Int64}}}
149149
edges:
150150
1:3
151151
weights: [1, 0]

src/misc.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ it will be dense (default).
126126
julia> using StatsBase
127127
128128
julia> indicatormat([1 2 2], 2)
129-
2×3 Array{Bool,2}:
129+
2×3 Matrix{Bool}:
130130
1 0 0
131131
0 1 1
132132
```

src/transformations.jl

+8-8
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@ and return a `ZScoreTransform` transformation object.
9393
julia> using StatsBase
9494
9595
julia> X = [0.0 -0.5 0.5; 0.0 1.0 2.0]
96-
2×3 Array{Float64,2}:
96+
2×3 Matrix{Float64}:
9797
0.0 -0.5 0.5
9898
0.0 1.0 2.0
9999
100100
julia> dt = fit(ZScoreTransform, X, dims=2)
101-
ZScoreTransform{Float64}(2, 2, [0.0, 1.0], [0.5, 1.0])
101+
ZScoreTransform{Float64, Vector{Float64}}(2, 2, [0.0, 1.0], [0.5, 1.0])
102102
103103
julia> StatsBase.transform(dt, X)
104-
2×3 Array{Float64,2}:
104+
2×3 Matrix{Float64}:
105105
0.0 -1.0 1.0
106106
-1.0 0.0 1.0
107107
```
@@ -247,15 +247,15 @@ and return a `UnitRangeTransform` transformation object.
247247
julia> using StatsBase
248248
249249
julia> X = [0.0 -0.5 0.5; 0.0 1.0 2.0]
250-
2×3 Array{Float64,2}:
250+
2×3 Matrix{Float64}:
251251
0.0 -0.5 0.5
252252
0.0 1.0 2.0
253253
254254
julia> dt = fit(UnitRangeTransform, X, dims=2)
255-
UnitRangeTransform{Float64}(2, 2, true, [-0.5, 0.0], [1.0, 0.5])
255+
UnitRangeTransform{Float64, Vector{Float64}}(2, 2, true, [-0.5, 0.0], [1.0, 0.5])
256256
257257
julia> StatsBase.transform(dt, X)
258-
2×3 Array{Float64,2}:
258+
2×3 Matrix{Float64}:
259259
0.5 0.0 1.0
260260
0.0 0.5 1.0
261261
```
@@ -353,12 +353,12 @@ end
353353
julia> using StatsBase
354354
355355
julia> standardize(ZScoreTransform, [0.0 -0.5 0.5; 0.0 1.0 2.0], dims=2)
356-
2×3 Array{Float64,2}:
356+
2×3 Matrix{Float64}:
357357
0.0 -1.0 1.0
358358
-1.0 0.0 1.0
359359
360360
julia> standardize(UnitRangeTransform, [0.0 -0.5 0.5; 0.0 1.0 2.0], dims=2)
361-
2×3 Array{Float64,2}:
361+
2×3 Matrix{Float64}:
362362
0.5 0.0 1.0
363363
0.0 0.5 1.0
364364
```

src/weights.jl

+18-7
Original file line numberDiff line numberDiff line change
@@ -536,8 +536,9 @@ wsumtype(::Type{T}, ::Type{W}) where {T,W} = typeof(zero(T) * zero(W) + zero(T)
536536
wsumtype(::Type{T}, ::Type{T}) where {T<:BlasReal} = T
537537

538538
"""
539-
wsum!(R, A, w, dim; init=true)
540-
539+
wsum!(R::AbstractArray, A::AbstractArray,
540+
w::AbstractWeights{<:Real}, dim::Int;
541+
init::Bool=true)
541542
Compute the weighted sum of `A` with weights `w` over the dimension `dim` and store
542543
the result in `R`. If `init=false`, the sum is added to `R` rather than starting
543544
from zero.
@@ -562,9 +563,24 @@ end
562563

563564
## extended sum! and wsum
564565

566+
"""
567+
sum!(R::AbstractArray, A::AbstractArray,
568+
w::AbstractWeights{<:Real}, dim::Int;
569+
init::Bool=true)
570+
571+
Compute the weighted sum of `A` with weights `w` over the dimension `dim` and store
572+
the result in `R`. If `init=false`, the sum is added to `R` rather than starting
573+
from zero.
574+
"""
565575
Base.sum!(R::AbstractArray, A::AbstractArray, w::AbstractWeights{<:Real}, dim::Int; init::Bool=true) =
566576
wsum!(R, A, w, dim; init=init)
567577

578+
"""
579+
sum(v::AbstractArray, w::AbstractVector{<:Real}; [dims])
580+
581+
Compute the weighted sum of an array `v` with weights `w`,
582+
optionally over the dimension `dims`.
583+
"""
568584
Base.sum(A::AbstractArray, w::AbstractWeights{<:Real}; dims::Union{Colon,Int}=:) =
569585
wsum(A, w, dims)
570586

@@ -576,11 +592,6 @@ end
576592

577593
##### Weighted means #####
578594

579-
"""
580-
wmean(v, w::AbstractVector)
581-
582-
Compute the weighted mean of an array `v` with weights `w`.
583-
"""
584595
function wmean(v::AbstractArray{<:Number}, w::AbstractVector)
585596
Base.depwarn("wmean is deprecated, use mean(v, weights(w)) instead.", :wmean)
586597
mean(v, weights(w))

0 commit comments

Comments
 (0)