-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Drop 0.7 tests and add the deprecated file.
- Loading branch information
Showing
3 changed files
with
158 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
environment: | ||
matrix: | ||
- julia_version: 0.7 | ||
- julia_version: 1.0 | ||
- julia_version: nightly | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ os: | |
- linux | ||
- osx | ||
julia: | ||
- 0.7 | ||
- 1.0 | ||
- nightly | ||
notifications: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
############################################################################### | ||
# Deprecations for calling impute on an Imputor with a custom AbstractContext # | ||
############################################################################### | ||
Base.@deprecate( | ||
impute(imp::Imputor, context::AbstractContext, data; kwargs...), | ||
impute(typeof(imp)(; context=context), data; kwargs...) | ||
) | ||
|
||
Base.@deprecate( | ||
impute!(imp::Imputor, context::AbstractContext, data; kwargs...), | ||
impute!(typeof(imp)(; context=context), data; kwargs...) | ||
) | ||
##################################################################### | ||
# Deprecate all impute calls where the first argument is an Imputor # | ||
##################################################################### | ||
""" | ||
impute!(data, method::Symbol=:interp, args...; limit::Float64=0.1) | ||
Looks up the `Imputor` type for the `method`, creates it and calls | ||
`impute!(imputor::Imputor, data, limit::Float64)` with it. | ||
# Arguments | ||
* `data`: the datset containing missing elements we should impute. | ||
* `method::Symbol`: the imputation method to use | ||
(options: [`:drop`, `:fill`, `:interp`, `:locf`, `:nocb`]) | ||
* `args::Any...`: any arguments you should pass to the `Imputor` constructor. | ||
* `limit::Float64`: missing data ratio limit/threshold (default: 0.1) | ||
""" | ||
function impute!(data, method::Symbol, args...; limit::Float64=0.1) | ||
Base.depwarn( | ||
""" | ||
impute!(data, method) is deprecated. | ||
Please use Impute.method!(data) or impute!(imputor, data). | ||
""", | ||
:impute! | ||
) | ||
imputor_type = imputation_methods[method] | ||
imputor = if length(args) > 0 | ||
imputor_type(args...; context=Context(; limit=limit)) | ||
else | ||
imputor_type(; context=Context(; limit=limit)) | ||
end | ||
|
||
return impute!(imputor, data) | ||
end | ||
|
||
""" | ||
impute!(data, missing::Function, method::Symbol=:interp, args...; limit::Float64=0.1) | ||
Creates the appropriate `Imputor` type and `Context` (using `missing` function) in order to call | ||
`impute!(imputor::Imputor, ctx::Context, data)` with them. | ||
# Arguments | ||
* `data`: the datset containing missing elements we should impute. | ||
* `missing::Function`: the missing data function to use | ||
* `method::Symbol`: the imputation method to use | ||
(options: [`:drop`, `:fill`, `:interp`, `:locf`, `:nocb`]) | ||
* `args::Any...`: any arguments you should pass to the `Imputor` constructor. | ||
* `limit::Float64`: missing data ratio limit/threshold (default: 0.1) | ||
""" | ||
function impute!(data, missing::Function, method::Symbol, args...; limit::Float64=0.1) | ||
Base.depwarn( | ||
""" | ||
impute!(data, missing, method) is deprecated. Please use impute!(imputor, data). | ||
""", | ||
:impute! | ||
) | ||
imputor_type = imputation_methods[method] | ||
imputor = if length(args) > 0 | ||
imputor_type(args...; context=Context(; limit=limit)) | ||
else | ||
imputor_type(; context=Context(; limit=limit)) | ||
end | ||
|
||
return impute!(imputor, data) | ||
end | ||
|
||
""" | ||
impute(data, args...; kwargs...) | ||
Copies the `data` before calling `impute!(new_data, args...; kwargs...)` | ||
""" | ||
function impute(data, args...; kwargs...) | ||
Base.depwarn( | ||
""" | ||
impute(data, args...; kwargs...) is deprecated. | ||
Please use Impute.method(data) or impute(imputor, data). | ||
""", | ||
:impute | ||
) | ||
return impute!(deepcopy(data), args...; kwargs...) | ||
end | ||
|
||
################################# | ||
# Deprecate the chain functions # | ||
################################# | ||
""" | ||
chain!(data, missing::Function, imputors::Imputor...; kwargs...) | ||
Creates a `Chain` with `imputors` and calls `impute!(imputor, missing, data; kwargs...)` | ||
""" | ||
function chain!(data, missing::Function, imputors::Imputor...; kwargs...) | ||
Base.depwarn( | ||
""" | ||
chain!(data, missing, imputors...) is deprecated. | ||
Please use data = imp1(data) |> imp2 |> imp3 | ||
""", | ||
:chain! | ||
) | ||
return chain!(data, imputors...; is_missing=missing, kwargs...) | ||
end | ||
|
||
""" | ||
chain!(data, imputors::Imputor...; kwargs...) | ||
Creates a `Chain` with `imputors` and calls `impute!(imputor, data; kwargs...)` | ||
""" | ||
function chain!(data, imputors::Imputor...; kwargs...) | ||
Base.depwarn( | ||
""" | ||
chain!(data, imputors...) is deprecated. | ||
Please use data = imp1(data) |> imp2 |> imp3 | ||
""", | ||
:chain! | ||
) | ||
ctx = Context(; kwargs...) | ||
|
||
for imputor in imputors | ||
imp = typeof(imputor)( | ||
(isa(x, AbstractContext) ? ctx : x for x in fieldvalues(imputor))... | ||
) | ||
data = impute!(imp, data) | ||
end | ||
|
||
return data | ||
end | ||
|
||
""" | ||
chain(data, args...; kwargs...) | ||
Copies the `data` before calling `chain!(data, args...; kwargs...)` | ||
""" | ||
function chain(data, args...; kwargs...) | ||
Base.depwarn( | ||
""" | ||
chain(data, args...) is deprecated. | ||
Please use result = imp1(data) |> imp2 |> imp3 | ||
""", | ||
:chain | ||
) | ||
result = deepcopy(data) | ||
return chain!(data, args...; kwargs...) | ||
end | ||
|
||
##################### | ||
# Misc Deprecations # | ||
##################### | ||
Base.@deprecate Fill(val; kwargs...) Fill(; value=val, kwargs...) |