Skip to content

Commit

Permalink
Update doctests for Julia 1.6 (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjram0s authored Mar 26, 2021
1 parent c3bb996 commit ad306f1
Show file tree
Hide file tree
Showing 13 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/chain.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ Compose new chains with the composition operator
julia> using Impute: Impute, Interpolate, NOCB, LOCF
julia> M = [missing 2.0 missing missing 5.0; 1.1 2.2 missing 4.4 missing]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
missing 2.0 missing missing 5.0
1.1 2.2 missing 4.4 missing
julia> C = Interpolate() ∘ NOCB() ∘ LOCF();
julia> C(M; dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
2.0 2.0 3.0 4.0 5.0
1.1 2.2 3.3 4.4 4.4
```
Expand Down
4 changes: 2 additions & 2 deletions src/declaremissings.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ a `missing`.
julia> using Impute: DeclareMissings, apply
julia> M = [1.0 2.0 -9999.0 NaN 5.0; 1.1 2.2 3.3 0.0 5.5]
2×5 Array{Float64,2}:
2×5 Matrix{Float64}:
1.0 2.0 -9999.0 NaN 5.0
1.1 2.2 3.3 0.0 5.5
julia> apply(M, DeclareMissings(; values=(NaN, -9999.0, 0.0)))
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
```
Expand Down
12 changes: 6 additions & 6 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ be handled independently.
julia> using Impute: Fill, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, Fill(); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 2.66667 2.66667 5.0
1.1 2.2 3.3 3.025 5.5
```
Expand Down Expand Up @@ -105,15 +105,15 @@ provided.
julia> using Impute: DropObs, impute
julia> M = [1.0 1.1; 2.0 2.2; missing 3.3; missing missing; 5.0 5.5]
5×2 Array{Union{Missing, Float64},2}:
5×2 Matrix{Union{Missing, Float64}}:
1.0 1.1
2.0 2.2
missing 3.3
missing missing
5.0 5.5
julia> impute(M, DropObs())
3×2 Array{Union{Missing, Float64},2}:
3×2 Matrix{Union{Missing, Float64}}:
1.0 1.1
2.0 2.2
5.0 5.5
Expand Down Expand Up @@ -175,12 +175,12 @@ Finds variables with too many missing values in a `AbstractMatrix` or
julia> using Impute: DropVars, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, DropVars())
2×3 Array{Union{Missing, Float64},2}:
2×3 Matrix{Union{Missing, Float64}}:
1.0 2.0 5.0
1.1 2.2 5.5
```
Expand Down
8 changes: 4 additions & 4 deletions src/functional.jl
Original file line number Diff line number Diff line change
Expand Up @@ -602,15 +602,15 @@ Imputation using k-Nearest Neighbor algorithm.
julia> using Impute, Missings
julia> data = allowmissing(reshape(sin.(1:20), 5, 4)); data[[2, 3, 7, 9, 13, 19]] .= missing; data
5×4 Array{Union{Missing, Float64},2}:
5×4 Matrix{Union{Missing, Float64}}:
0.841471 -0.279415 -0.99999 -0.287903
missing missing -0.536573 -0.961397
missing 0.989358 missing -0.750987
-0.756802 missing 0.990607 missing
-0.958924 -0.544021 0.650288 0.912945
julia> result = Impute.knn(data; dims=:cols)
5×4 Array{Union{Missing, Float64},2}:
5×4 Matrix{Union{Missing, Float64}}:
0.841471 -0.279415 -0.99999 -0.287903
-0.756802 0.989358 -0.536573 -0.961397
-0.756802 0.989358 -0.536573 -0.750987
Expand Down Expand Up @@ -641,15 +641,15 @@ over low-rank SVD approximations.
julia> using Impute, Missings
julia> data = allowmissing(reshape(sin.(1:20), 5, 4)); data[[2, 3, 7, 9, 13, 19]] .= missing; data
5×4 Array{Union{Missing, Float64},2}:
5×4 Matrix{Union{Missing, Float64}}:
0.841471 -0.279415 -0.99999 -0.287903
missing missing -0.536573 -0.961397
missing 0.989358 missing -0.750987
-0.756802 missing 0.990607 missing
-0.958924 -0.544021 0.650288 0.912945
julia> result = Impute.svd(data; dims=:cols)
5×4 Array{Union{Missing, Float64},2}:
5×4 Matrix{Union{Missing, Float64}}:
0.841471 -0.279415 -0.99999 -0.287903
0.220258 0.555829 -0.536573 -0.961397
-0.372745 0.989358 0.533193 -0.750987
Expand Down
10 changes: 5 additions & 5 deletions src/imputors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ If this is not the desired behaviour then you should overload this method or spe
julia> using Impute: Interpolate, impute
julia> v = [1.0, 2.0, missing, missing, 5.0]
5-element Array{Union{Missing, Float64},1}:
5-element Vector{Union{Missing, Float64}}:
1.0
2.0
missing
missing
5.0
julia> impute(v, Interpolate())
5-element Array{Union{Missing, Float64},1}:
5-element Vector{Union{Missing, Float64}}:
1.0
2.0
3.0
Expand Down Expand Up @@ -106,17 +106,17 @@ Optionally, you can specify the dimension to impute along.
julia> using Impute: Interpolate, impute!
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute!(M, Interpolate(); dims=1)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 3.0 4.0 5.0
1.1 2.2 3.3 4.4 5.5
julia> M
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 3.0 4.0 5.0
1.1 2.2 3.3 4.4 5.5
```
Expand Down
4 changes: 2 additions & 2 deletions src/imputors/interp.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ that all missing values will be imputed.
julia> using Impute: Interpolate, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, Interpolate(); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 3.0 4.0 5.0
1.1 2.2 3.3 4.4 5.5
```
Expand Down
4 changes: 2 additions & 2 deletions src/imputors/locf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ that all missing values will be imputed.
julia> using Impute: LOCF, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, LOCF(); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 2.0 2.0 5.0
1.1 2.2 3.3 3.3 5.5
```
Expand Down
4 changes: 2 additions & 2 deletions src/imputors/nocb.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ that all missing values will be imputed.
julia> using Impute: NOCB, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, NOCB(); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 5.0 5.0 5.0
1.1 2.2 3.3 5.5 5.5
```
Expand Down
4 changes: 2 additions & 2 deletions src/imputors/replace.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ If the input data is of a different type then the no replacement will be perform
julia> using Impute: Replace, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, Replace(; values=0.0); dims=2)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 0.0 0.0 5.0
1.1 2.2 3.3 0.0 5.5
```
Expand Down
4 changes: 2 additions & 2 deletions src/imputors/srs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ for both categorical and continuous data.
julia> using Random; using Impute: SRS, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, SRS(; rng=MersenneTwister(1234)); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 1.0 2.0 5.0
1.1 2.2 3.3 3.3 5.5
```
Expand Down
10 changes: 5 additions & 5 deletions src/imputors/substitute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ Substitute missing values with a summary statistic over the non-missing values.
julia> using Statistics; using Impute: Substitute, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> impute(M, Substitute(); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 2.0 2.0 5.0
1.1 2.2 3.3 2.75 5.5
julia> impute(M, Substitute(; statistic=mean); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 2.66667 2.66667 5.0
1.1 2.2 3.3 3.025 5.5
```
Expand Down Expand Up @@ -69,14 +69,14 @@ Substitute missing values with a weighted summary statistic over the non-missing
julia> using Statistics, StatsBase; using Impute: WeightedSubstitute, impute
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
julia> wv = weights([0.5, 0.2, 0.3, 0.1, 0.4]);
julia> impute(M, WeightedSubstitute(; weights=wv); dims=:rows)
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 2.75 2.75 5.0
1.1 2.2 3.3 3.11667 5.5
```
Expand Down
2 changes: 1 addition & 1 deletion src/validators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ provided is returned without mutation. See [`Validator`](@ref) for the minimum i
julia> using Test; using Impute: Threshold, ThresholdError, validate
julia> M = [1.0 2.0 missing missing 5.0; 1.1 2.2 3.3 missing 5.5]
2×5 Array{Union{Missing, Float64},2}:
2×5 Matrix{Union{Missing, Float64}}:
1.0 2.0 missing missing 5.0
1.1 2.2 3.3 missing 5.5
Expand Down
4 changes: 2 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ using Impute:

# Start running doctests before we wrap up technical changes and work
# on more documentation
# The doctests fail on x86, so only run them on 64-bit hardware
Sys.WORD_SIZE == 64 && doctest(Impute)
# The doctests fail on x86, so only run them on 64-bit hardware & Julia 1.6
Sys.WORD_SIZE == 64 && v"1.6" <= VERSION < v"1.7" && doctest(Impute)
end

2 comments on commit ad306f1

@rofinn
Copy link
Member

@rofinn rofinn commented on ad306f1 Mar 29, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/33099

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.4 -m "<description of version>" ad306f1e7b11ab9d3b293b0e99655d6d25ba5087
git push origin v0.6.4

Please sign in to comment.