Skip to content

Commit 7b03697

Browse files
authoredMar 10, 2025··
Fix glmnet penalty check (#1262)
* update snap * changes for #1261 * use cran reticulate
1 parent 6377bf1 commit 7b03697

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed
 

‎.github/workflows/R-CMD-check.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ jobs:
6161
extra-packages: any::rcmdcheck
6262
needs: check
6363

64-
- name: Install dev reticulate
65-
run: pak::pkg_install('rstudio/reticulate')
64+
- name: Install reticulate
65+
run: pak::pkg_install('reticulate')
6666
shell: Rscript {0}
6767

6868
- name: Install Miniconda

‎NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# parsnip (development version)
22

3+
## Bug Fixes
4+
5+
* Fixed a bug that errored when tidying a glmnet object with a penalty value greater than one (#1261).
6+
37
# parsnip 1.3.0
48

59
## New Features

‎R/tidy_glmnet.R

+5-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ get_glmn_coefs <- function(x, penalty = 0.01) {
4848
res <- tibble::as_tibble(res) %>% mutate(term = rn, penalty = penalty)
4949
res <- dplyr::select(res, term, estimate, penalty)
5050
if (is.list(res$estimate)) {
51-
res$estimate <- purrr::map(res$estimate, ~ as_tibble(as.matrix(.x), rownames = "term"))
51+
res$estimate <- purrr::map(
52+
res$estimate,
53+
~ as_tibble(as.matrix(.x), rownames = "term")
54+
)
5255
res <- tidyr::unnest(res, cols = c(estimate), names_repair = "minimal")
5356
names(res) <- c("class", "term", "estimate", "penalty")
5457
}
@@ -61,6 +64,6 @@ tidy_glmnet <- function(x, penalty = NULL, ..., call = caller_env()) {
6164
if (is.null(penalty)) {
6265
penalty <- x$spec$args$penalty
6366
}
64-
check_number_decimal(penalty, min = 0, max = 1, allow_null = TRUE, call = call)
67+
check_number_decimal(penalty, min = 0, allow_null = TRUE, call = call)
6568
get_glmn_coefs(x$fit, penalty = penalty)
6669
}

‎tests/testthat/_snaps/mlp_keras.md

+2-9
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
# keras execution, classification
2-
3-
Code
4-
res <- parsnip::fit(hpc_keras, class ~ novar, data = hpc, control = ctrl)
5-
Condition
6-
Error:
7-
! object 'novar' not found
8-
91
# all keras activation functions
102

113
Code
@@ -14,4 +6,5 @@
146
Class ~ A + B, data = modeldata::two_class_dat)
157
Condition
168
Error in `parsnip::keras_mlp()`:
17-
! `activation` should be one of: elu, exponential, gelu, hard_sigmoid, linear, relu, selu, sigmoid, softmax, softplus, softsign, swish, and tanh, not "invalid".
9+
! `activation` should be one of: elu, exponential, gelu, hardsigmoid, linear, relu, selu, sigmoid, softmax, softplus, softsign, swish, and tanh, not "invalid".
10+

0 commit comments

Comments
 (0)
Please sign in to comment.