diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 33e102817..9f7fbc3c7 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -61,8 +61,8 @@ jobs: extra-packages: any::rcmdcheck needs: check - - name: Install dev reticulate - run: pak::pkg_install('rstudio/reticulate') + - name: Install reticulate + run: pak::pkg_install('reticulate') shell: Rscript {0} - name: Install Miniconda diff --git a/NEWS.md b/NEWS.md index b2dc83a62..3343978ae 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # parsnip (development version) +## Bug Fixes + +* Fixed a bug that errored when tidying a glmnet object with a penalty value greater than one (#1261). + # parsnip 1.3.0 ## New Features diff --git a/R/tidy_glmnet.R b/R/tidy_glmnet.R index c9ae65c4c..123375388 100644 --- a/R/tidy_glmnet.R +++ b/R/tidy_glmnet.R @@ -48,7 +48,10 @@ get_glmn_coefs <- function(x, penalty = 0.01) { res <- tibble::as_tibble(res) %>% mutate(term = rn, penalty = penalty) res <- dplyr::select(res, term, estimate, penalty) if (is.list(res$estimate)) { - res$estimate <- purrr::map(res$estimate, ~ as_tibble(as.matrix(.x), rownames = "term")) + res$estimate <- purrr::map( + res$estimate, + ~ as_tibble(as.matrix(.x), rownames = "term") + ) res <- tidyr::unnest(res, cols = c(estimate), names_repair = "minimal") names(res) <- c("class", "term", "estimate", "penalty") } @@ -61,6 +64,6 @@ tidy_glmnet <- function(x, penalty = NULL, ..., call = caller_env()) { if (is.null(penalty)) { penalty <- x$spec$args$penalty } - check_number_decimal(penalty, min = 0, max = 1, allow_null = TRUE, call = call) + check_number_decimal(penalty, min = 0, allow_null = TRUE, call = call) get_glmn_coefs(x$fit, penalty = penalty) } diff --git a/tests/testthat/_snaps/mlp_keras.md b/tests/testthat/_snaps/mlp_keras.md index 02479ada2..62397f66b 100644 --- a/tests/testthat/_snaps/mlp_keras.md +++ b/tests/testthat/_snaps/mlp_keras.md @@ -1,11 +1,3 @@ -# keras execution, classification - - Code - res <- parsnip::fit(hpc_keras, class ~ novar, data = hpc, control = ctrl) - Condition - Error: - ! object 'novar' not found - # all keras activation functions Code @@ -14,4 +6,5 @@ Class ~ A + B, data = modeldata::two_class_dat) Condition Error in `parsnip::keras_mlp()`: - ! `activation` should be one of: elu, exponential, gelu, hard_sigmoid, linear, relu, selu, sigmoid, softmax, softplus, softsign, swish, and tanh, not "invalid". \ No newline at end of file + ! `activation` should be one of: elu, exponential, gelu, hardsigmoid, linear, relu, selu, sigmoid, softmax, softplus, softsign, swish, and tanh, not "invalid". +