-
Notifications
You must be signed in to change notification settings - Fork 12
Simplify Imputor API #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
cdef813
f1c863f
640e2cb
1500ece
4772961
6e6497e
43fc0fc
c992d51
bc15b8f
10f3737
8ed73e4
850d119
0bba5aa
af45737
8213ce3
27dfb99
701d85b
bb98aa9
6c3b6d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| """ | ||
| Assertion | ||
|
|
||
| An Assertion stores settings for checking the validity of a `AbstractArray` or `Tables.table` containing missing values. | ||
| New assertions are expected to subtype `Impute.Assertion` and, at minimum, | ||
| implement the `assert(data::AbstractVector{Union{T, Missing}}, ::<MyAssertion>)` method. | ||
| """ | ||
| abstract type Assertion end | ||
|
|
||
|
|
||
| """ | ||
| assert(data, a::Assertion; kwargs...) | ||
|
|
||
| If the assertion `a` fails then an `AssertionError` is thrown, otherwise the `data` | ||
| provided is returned without mutation. | ||
|
|
||
rofinn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Keywords | ||
| * `dims`: The dimension to apply the assertion along (e.g., observations dim) | ||
| """ | ||
rofinn marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| assert | ||
|
|
||
| # A couple fallbacks for matrices and tables | ||
| function assert(data::AbstractMatrix, a::Assertion; dims=1) | ||
| for var in varwise(data; dims=dims) | ||
| assert(var, a) | ||
rofinn marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| end | ||
| return data | ||
| end | ||
|
|
||
| function assert(table, a::Assertion) | ||
| istable(table) || throw(MethodError(a, (table, a))) | ||
| columntable = Tables.columns(table) | ||
|
|
||
| for cname in propertynames(columntable) | ||
| assert(getproperty(columntable, cname), a) | ||
| end | ||
|
|
||
| return table | ||
| end | ||
|
|
||
| include("assertions/threshold.jl") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would we want it here, or would it be nicer to put these all in the top file? ChainRules puts them all in the top as does ChainRulesCore
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess I prefer seeing the abstract type API first, but I don't have a strong opinion. What's the benefit to putting it earlier?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess marginally Mostly just for constancy?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, n/m looks like julia doesn't like that because then the threshold code doesn't know about the |
||
Uh oh!
There was an error while loading. Please reload this page.