From ad306f1e7b11ab9d3b293b0e99655d6d25ba5087 Mon Sep 17 00:00:00 2001 From: Mary Jo Ramos Date: Fri, 26 Mar 2021 16:04:53 -0500 Subject: [PATCH] Update doctests for Julia 1.6 (#115) --- src/chain.jl | 4 ++-- src/declaremissings.jl | 4 ++-- src/deprecated.jl | 12 ++++++------ src/functional.jl | 8 ++++---- src/imputors.jl | 10 +++++----- src/imputors/interp.jl | 4 ++-- src/imputors/locf.jl | 4 ++-- src/imputors/nocb.jl | 4 ++-- src/imputors/replace.jl | 4 ++-- src/imputors/srs.jl | 4 ++-- src/imputors/substitute.jl | 10 +++++----- src/validators.jl | 2 +- test/runtests.jl | 4 ++-- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/chain.jl b/src/chain.jl index f7c773b..b6c772d 100644 --- a/src/chain.jl +++ b/src/chain.jl @@ -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 ``` diff --git a/src/declaremissings.jl b/src/declaremissings.jl index 9080f58..0093a7b 100644 --- a/src/declaremissings.jl +++ b/src/declaremissings.jl @@ -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 ``` diff --git a/src/deprecated.jl b/src/deprecated.jl index d467d51..5d5ce90 100644 --- a/src/deprecated.jl +++ b/src/deprecated.jl @@ -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 ``` @@ -105,7 +105,7 @@ 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 @@ -113,7 +113,7 @@ julia> M = [1.0 1.1; 2.0 2.2; missing 3.3; missing missing; 5.0 5.5] 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 @@ -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 ``` diff --git a/src/functional.jl b/src/functional.jl index 8f83f69..2ac66ed 100644 --- a/src/functional.jl +++ b/src/functional.jl @@ -602,7 +602,7 @@ 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 @@ -610,7 +610,7 @@ julia> data = allowmissing(reshape(sin.(1:20), 5, 4)); data[[2, 3, 7, 9, 13, 19] -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 @@ -641,7 +641,7 @@ 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 @@ -649,7 +649,7 @@ julia> data = allowmissing(reshape(sin.(1:20), 5, 4)); data[[2, 3, 7, 9, 13, 19] -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 diff --git a/src/imputors.jl b/src/imputors.jl index 04f3d66..838cd97 100644 --- a/src/imputors.jl +++ b/src/imputors.jl @@ -57,7 +57,7 @@ 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 @@ -65,7 +65,7 @@ julia> v = [1.0, 2.0, missing, missing, 5.0] 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 @@ -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 ``` diff --git a/src/imputors/interp.jl b/src/imputors/interp.jl index 720a521..55498d5 100644 --- a/src/imputors/interp.jl +++ b/src/imputors/interp.jl @@ -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 ``` diff --git a/src/imputors/locf.jl b/src/imputors/locf.jl index ba92506..f459149 100644 --- a/src/imputors/locf.jl +++ b/src/imputors/locf.jl @@ -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 ``` diff --git a/src/imputors/nocb.jl b/src/imputors/nocb.jl index 3b7b492..20ba081 100644 --- a/src/imputors/nocb.jl +++ b/src/imputors/nocb.jl @@ -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 ``` diff --git a/src/imputors/replace.jl b/src/imputors/replace.jl index 816f24f..81f4583 100644 --- a/src/imputors/replace.jl +++ b/src/imputors/replace.jl @@ -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 ``` diff --git a/src/imputors/srs.jl b/src/imputors/srs.jl index bd69e9f..77d8806 100644 --- a/src/imputors/srs.jl +++ b/src/imputors/srs.jl @@ -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 ``` diff --git a/src/imputors/substitute.jl b/src/imputors/substitute.jl index 1f9436a..f97f0b9 100644 --- a/src/imputors/substitute.jl +++ b/src/imputors/substitute.jl @@ -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 ``` @@ -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 ``` diff --git a/src/validators.jl b/src/validators.jl index 047e95f..1c93ad1 100644 --- a/src/validators.jl +++ b/src/validators.jl @@ -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 diff --git a/test/runtests.jl b/test/runtests.jl index bf1a5e5..536ae24 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -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