Skip to content

Commit

Permalink
remove unneeded namespacing
Browse files Browse the repository at this point in the history
  • Loading branch information
simonpcouch committed Apr 22, 2024
1 parent 025ae83 commit 319ac5f
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 19 deletions.
16 changes: 8 additions & 8 deletions R/container.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#' @export
container <- function(mode = "unknown", type = "unknown", outcome = character(0),
estimate = character(0), probabilities = character(0),
time = character(0), call = rlang::current_env()) {
time = character(0), call = current_env()) {
dat <-
list(
outcome = outcome,
Expand All @@ -37,13 +37,13 @@ container <- function(mode = "unknown", type = "unknown", outcome = character(0)
}

new_container <- function(mode, type, operations, columns, ptype, call) {
mode <- rlang::arg_match0(mode, c("unknown", "regression", "classification", "censored regression"))
mode <- arg_match0(mode, c("unknown", "regression", "classification", "censored regression"))

if (mode == "regression") {
type <- "regression"
}

type <- rlang::arg_match0(type, c("unknown", "regression", "binary", "multiclass"))
type <- arg_match0(type, c("unknown", "regression", "binary", "multiclass"))

if (!is.list(operations)) {
cli::cli_abort("The {.arg operations} argument should be a list.", call = call)
Expand Down Expand Up @@ -88,23 +88,23 @@ print.container <- function(x, ...) {

#' @export
fit.container <- function(object, .data, outcome, estimate, probabilities = c(),
time = c(), call = rlang::current_env(), ...) {
time = c(), call = current_env(), ...) {

# ------------------------------------------------------------------------------
# set columns via tidyselect

dat <- list()
dat$outcome <- names(tidyselect::eval_select(rlang::enquo(outcome), .data))
dat$estimate <- names(tidyselect::eval_select(rlang::enquo(estimate), .data))
dat$outcome <- names(tidyselect::eval_select(enquo(outcome), .data))
dat$estimate <- names(tidyselect::eval_select(enquo(estimate), .data))

probabilities <- tidyselect::eval_select(rlang::enquo(probabilities), .data)
probabilities <- tidyselect::eval_select(enquo(probabilities), .data)
if (length(probabilities) > 0) {
dat$probabilities <- names(probabilities)
} else {
dat$probabilities <- character(0)
}

time <- tidyselect::eval_select(rlang::enquo(time), .data)
time <- tidyselect::eval_select(enquo(time), .data)
if (length(time) > 0) {
dat$time <- names(time)
} else {
Expand Down
4 changes: 2 additions & 2 deletions R/equivocal_zone.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ adjust_equivocal_zone <- function(x, value = 0.1, threshold = 1 / 2) {
operations = c(x$operations, list(op)),
columns = x$dat,
ptype = x$ptype,
call = rlang::current_env()
call = current_env()
)
}

Expand Down Expand Up @@ -81,7 +81,7 @@ predict.equivocal_zone <- function(object, new_data, parent, ...) {
est_nm <- parent$columns$estimate
prob_nm <- parent$columns$probabilities[1]
lvls <- levels(new_data[[ est_nm ]])
col_syms <- rlang::syms(prob_nm[1])
col_syms <- syms(prob_nm[1])
cls_pred <- probably::make_two_class_pred(new_data[[prob_nm]], levels = lvls,
buffer = object$arguments$value,
threshold = object$arguments$threshold)
Expand Down
2 changes: 1 addition & 1 deletion R/numeric_calibration.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ adjust_numeric_calibration <- function(x, calibrator) {
operations = c(x$operations, list(op)),
columns = x$dat,
ptype = x$ptype,
call = rlang::current_env()
call = current_env()
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/numeric_range.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ adjust_numeric_range <- function(x, lower_limit = -Inf, upper_limit = Inf) {
operations = c(x$operations, list(op)),
columns = x$dat,
ptype = x$ptype,
call = rlang::current_env()
call = current_env()
)
}

Expand Down
4 changes: 2 additions & 2 deletions R/operation.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ input_vals <- c("numeric", "probability", "class", "everything")
output_vals <- c("numeric", "probability_class", "class", "everything")

new_operation <- function(cls, inputs, outputs, arguments, results = list(trained = FALSE), ...) {
inputs <- rlang::arg_match0(inputs, input_vals)
outputs <- rlang::arg_match0(outputs, output_vals)
inputs <- arg_match0(inputs, input_vals)
outputs <- arg_match0(outputs, output_vals)

if (!any(names(results) == "trained")) {
cli::cli_abort("The {.arg results} slot requires a logical variable called \\
Expand Down
4 changes: 2 additions & 2 deletions R/predictions_custom.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#' @export
adjust_predictions_custom <- function(x, ..., .pkgs = character(0)) {

cmds <- rlang::enquos(...)
cmds <- enquos(...)

op <-
new_operation(
Expand All @@ -43,7 +43,7 @@ adjust_predictions_custom <- function(x, ..., .pkgs = character(0)) {
operations = c(x$operations, list(op)),
columns = x$dat,
ptype = x$ptype,
call = rlang::current_env()
call = current_env()
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/prob_threshold.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ adjust_probability_threshold <- function(x, threshold = 0.5) {
operations = c(x$operations, list(op)),
columns = x$dat,
ptype = x$ptype,
call = rlang::current_env()
call = current_env()
)
}

Expand Down
2 changes: 1 addition & 1 deletion R/probability_calibration.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ adjust_probability_calibration <- function(x, calibrator) {
operations = c(x$operations, list(op)),
columns = x$dat,
ptype = x$ptype,
call = rlang::current_env()
call = current_env()
)
}

Expand Down
2 changes: 1 addition & 1 deletion man/container.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 319ac5f

Please sign in to comment.