Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Simon P. Couch <[email protected]>
  • Loading branch information
topepo and simonpcouch authored Oct 22, 2024
1 parent f79274b commit e4ea7a3
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion R/condense_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
#'
#' ctrl <- condense_control(ctrl, control_parsnip())
#' str(ctrl)
condense_control <- function(x, ref, call = rlang::caller_env()) {
condense_control <- function(x, ref, ..., call = rlang::caller_env()) {
check_dots_empty()
mismatch <- setdiff(names(ref), names(x))
if (length(mismatch)) {
cli::cli_abort(
Expand Down
3 changes: 1 addition & 2 deletions R/contr_one_hot.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ contr_one_hot <- function(n, contrasts = TRUE, sparse = FALSE) {
}

if (is.character(n)) {
check_character(n, empty = FALSE)
if (length(n) < 1) {
cli::cli_abort("A character vector for {.arg n} cannot be empty.")
cli::cli_abort("{.arg n} cannot be empty.")
}
names <- n
n <- length(names)
Expand Down
9 changes: 6 additions & 3 deletions R/glmnet-engines.R
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,8 @@ format_glmnet_multinom_class <- function(pred, penalty, lvl, n_obs) {
{.pkg tune} package.",
"i" = "To predict multiple penalties, use {.fn multi_predict}."
),
call = call)
call = call
)
}
}

Expand All @@ -395,7 +396,8 @@ format_glmnet_multinom_class <- function(pred, penalty, lvl, n_obs) {
"{.arg penalty} should be a single numeric value.",
"i" = "{.fn multi_predict} can be used to get multiple predictions per row of data."
),
call = call)
call = call
)
}
}

Expand All @@ -406,7 +408,8 @@ format_glmnet_multinom_class <- function(pred, penalty, lvl, n_obs) {
{.arg object$fit$lambda}. Predicting with a value of {.arg penalty}
will give incorrect results from `glmnet()`."
),
call = call)
call = call
)
}

penalty
Expand Down
1 change: 0 additions & 1 deletion tests/testthat/test-condense_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ test_that("condense_control works", {
invisible(control)
}
expect_snapshot(error = TRUE, control_test(ctrl))

})
2 changes: 0 additions & 2 deletions tests/testthat/test-contr_one_hot.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
test_that('one-hot encoding contrasts', {

contr_mat <- contr_one_hot(12)
expect_equal(colnames(contr_mat), paste(1:12))
expect_equal(rownames(contr_mat), paste(1:12))
Expand All @@ -17,5 +16,4 @@ test_that('one-hot encoding contrasts', {
expect_snapshot(contr_one_hot(list()), error = TRUE)
expect_snapshot(contr_one_hot(2, contrast = FALSE))
expect_snapshot(contr_one_hot(2, sparse = TRUE))

})
1 change: 0 additions & 1 deletion tests/testthat/test-misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ test_that('parsnip objects', {
expect_false(has_multi_predict(lm_idea))
expect_snapshot(error = TRUE, predict(lm_idea, mtcars))


lm_fit <- fit(lm_idea, mpg ~ ., data = mtcars)
expect_false(has_multi_predict(lm_fit))
expect_false(has_multi_predict(extract_fit_engine(lm_fit)))
Expand Down

0 comments on commit e4ea7a3

Please sign in to comment.