Skip to content
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

Additional check functions #86

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export(schedule_decay_time)
export(schedule_step)
export(set_learn_rate)
export(tunable)
import(rlang)
import(torch)
importFrom(dplyr,"%>%")
importFrom(generics,tunable)
Expand Down
1 change: 1 addition & 0 deletions R/aaa.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#' @import torch
#' @import rlang
#' @importFrom stats complete.cases model.matrix terms
#' @importFrom utils globalVariables
#'
Expand Down
25 changes: 25 additions & 0 deletions R/checks.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,28 @@
# Additional type checkers designed for testing argument values.

check_number_whole_vec <- function(x, call = rlang::caller_env(), arg = rlang::caller_arg(x), ...) {

for (i in x) {
Copy link
Member Author

Choose a reason for hiding this comment

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

The downside here is that we only catch one violation at a time.

Choose a reason for hiding this comment

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

I would imagine there's a pretty steep performance penalty here, too. This is the same kind of performance issue that led to tidymodels/parsnip#835.

Maybe an error could be conditional on rlang::is_integerish()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is it steep for checking arguments (not data)? We need some sort of (short length) numeric vector checks with min/max/na/null options.

check_number_whole(i, arg = arg, call = call, ...)
}
x <- as.integer(x)
topepo marked this conversation as resolved.
Show resolved Hide resolved
invisible(x)
}

check_number_decimal_vec <- function(x, call = rlang::caller_env(), ...) {

Choose a reason for hiding this comment

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

Same edits to this function.

cl <- match.call()
arg <- as.character(cl$x)
topepo marked this conversation as resolved.
Show resolved Hide resolved

for (i in x) {
check_number_decimal(i, arg = arg, call = call, ...)
}
invisible(x)
}

# ------------------------------------------------------------------------------
# soon to be replaced checkers


check_missing_data <- function(x, y, fn = "some function", verbose = FALSE) {
compl_data <- complete.cases(x, y)
if (any(!compl_data)) {
Expand Down
Loading
Loading