From 2fd951c7ba4589edb46eb8a54c723691583c4a9c Mon Sep 17 00:00:00 2001 From: topepo Date: Fri, 24 Jan 2025 15:42:54 -0500 Subject: [PATCH 1/2] updates for parsnip 1.2.1.9004 --- DESCRIPTION | 4 ++-- R/arguments.R | 2 +- man/set_args.cluster_spec.Rd | 2 +- man/set_engine.cluster_spec.Rd | 2 +- man/set_mode.cluster_spec.Rd | 6 ++++-- tests/testthat/_snaps/arguments.md | 15 ++++++++------- tests/testthat/_snaps/hier_clust.md | 4 ++-- tests/testthat/_snaps/k_means.md | 4 ++-- tidyclust.Rproj | 1 + 9 files changed, 22 insertions(+), 18 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index e676913a..e383e914 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,7 +17,7 @@ Depends: R (>= 3.6) Imports: cli (>= 3.0.0), - dials (>= 1.1.0), + dials (>= 1.3.0), dplyr (>= 1.0.9), flexclust (>= 1.3-6), foreach, @@ -25,7 +25,7 @@ Imports: glue (>= 1.6.2), hardhat (>= 1.0.0), modelenv (>= 0.1.0), - parsnip (>= 1.0.2), + parsnip (>= 1.2.1.9004), prettyunits (>= 1.1.0), Rfast (>= 2.0.6), rlang (>= 1.0.6), diff --git a/R/arguments.R b/R/arguments.R index eb44bebd..ebd1bf69 100644 --- a/R/arguments.R +++ b/R/arguments.R @@ -101,7 +101,7 @@ set_args.cluster_spec <- function(object, ...) { #' @inheritParams parsnip::set_mode #' @return An updated [`cluster_spec`] object. #' @export -set_mode.cluster_spec <- function(object, mode) { +set_mode.cluster_spec <- function(object, mode, ...) { cls <- class(object)[1] if (rlang::is_missing(mode)) { spec_modes <- rlang::env_get( diff --git a/man/set_args.cluster_spec.Rd b/man/set_args.cluster_spec.Rd index a9143d23..d36e8a90 100644 --- a/man/set_args.cluster_spec.Rd +++ b/man/set_args.cluster_spec.Rd @@ -7,7 +7,7 @@ \method{set_args}{cluster_spec}(object, ...) } \arguments{ -\item{object}{A model specification.} +\item{object}{A \link[parsnip:model_spec]{model specification}.} \item{...}{One or more named model arguments.} } diff --git a/man/set_engine.cluster_spec.Rd b/man/set_engine.cluster_spec.Rd index cfd14127..f0600ff0 100644 --- a/man/set_engine.cluster_spec.Rd +++ b/man/set_engine.cluster_spec.Rd @@ -7,7 +7,7 @@ \method{set_engine}{cluster_spec}(object, engine, ...) } \arguments{ -\item{object}{A model specification.} +\item{object}{A \link[parsnip:model_spec]{model specification}.} \item{engine}{A character string for the software that should be used to fit the model. This is highly dependent on the type diff --git a/man/set_mode.cluster_spec.Rd b/man/set_mode.cluster_spec.Rd index 5c620021..03d6b7d9 100644 --- a/man/set_mode.cluster_spec.Rd +++ b/man/set_mode.cluster_spec.Rd @@ -4,13 +4,15 @@ \alias{set_mode.cluster_spec} \title{Change mode of a cluster specification} \usage{ -\method{set_mode}{cluster_spec}(object, mode) +\method{set_mode}{cluster_spec}(object, mode, ...) } \arguments{ -\item{object}{A model specification.} +\item{object}{A \link[parsnip:model_spec]{model specification}.} \item{mode}{A character string for the model type (e.g. "classification" or "regression")} + +\item{...}{One or more named model arguments.} } \value{ An updated \code{\link{cluster_spec}} object. diff --git a/tests/testthat/_snaps/arguments.md b/tests/testthat/_snaps/arguments.md index a23f6fa5..e1f2b21c 100644 --- a/tests/testthat/_snaps/arguments.md +++ b/tests/testthat/_snaps/arguments.md @@ -12,29 +12,30 @@ k_means() %>% set_mode() Condition Error in `modelenv::stop_incompatible_mode()`: - ! Available modes for model type k_means are: 'unknown', 'partition' + x Available modes for model type k_means are: + * "unknown" and "partition". --- Code k_means() %>% set_mode(2) Condition - Error in `modelenv::check_spec_mode_engine_val()`: - ! '2' is not a known mode for model `k_means()`. + Error in `set_mode()`: + ! 2 is not a known mode for model `k_means()`. --- Code k_means() %>% set_mode("haberdashery") Condition - Error in `modelenv::check_spec_mode_engine_val()`: - ! 'haberdashery' is not a known mode for model `k_means()`. + Error in `set_mode()`: + ! "haberdashery" is not a known mode for model `k_means()`. # can't set a mode that isn't allowed by the model spec Code set_mode(k_means(), "classification") Condition - Error in `modelenv::check_spec_mode_engine_val()`: - ! 'classification' is not a known mode for model `k_means()`. + Error in `set_mode()`: + ! "classification" is not a known mode for model `k_means()`. diff --git a/tests/testthat/_snaps/hier_clust.md b/tests/testthat/_snaps/hier_clust.md index 16bbb373..b0c0b6f1 100644 --- a/tests/testthat/_snaps/hier_clust.md +++ b/tests/testthat/_snaps/hier_clust.md @@ -3,8 +3,8 @@ Code hier_clust(mode = "bogus") Condition - Error in `modelenv::check_spec_mode_engine_val()`: - ! 'bogus' is not a known mode for model `hier_clust()`. + Error in `new_cluster_spec()`: + ! "bogus" is not a known mode for model `hier_clust()`. --- diff --git a/tests/testthat/_snaps/k_means.md b/tests/testthat/_snaps/k_means.md index fd1dbd65..50837d21 100644 --- a/tests/testthat/_snaps/k_means.md +++ b/tests/testthat/_snaps/k_means.md @@ -3,8 +3,8 @@ Code k_means(mode = "bogus") Condition - Error in `modelenv::check_spec_mode_engine_val()`: - ! 'bogus' is not a known mode for model `k_means()`. + Error in `new_cluster_spec()`: + ! "bogus" is not a known mode for model `k_means()`. --- diff --git a/tidyclust.Rproj b/tidyclust.Rproj index 7f1b52b6..ee85d219 100644 --- a/tidyclust.Rproj +++ b/tidyclust.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 7aa6e982-3f23-4734-8da7-2ab97b3d66a5 RestoreWorkspace: No SaveWorkspace: No From 1ef1f2380f62df7321cecffe10eced9858226af4 Mon Sep 17 00:00:00 2001 From: topepo Date: Fri, 24 Jan 2025 15:43:02 -0500 Subject: [PATCH 2/2] updates for dials 1.3.0 --- R/tune_cluster.R | 4 ++-- tests/testthat/_snaps/tune_cluster.md | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/tune_cluster.R b/R/tune_cluster.R index 0cf06310..57338d43 100644 --- a/R/tune_cluster.R +++ b/R/tune_cluster.R @@ -222,7 +222,7 @@ tune_cluster_loop <- function(resamples, # created by `eval()`. This causes the handler to run much too early. By evaluating in # a local environment, we prevent `defer()`/`on.exit()` from finding the short-lived # context of `%op%`. Instead it looks all the way up here to register the handler. - + results <- local({ suppressPackageStartupMessages( foreach::foreach( @@ -1040,7 +1040,7 @@ check_grid <- function(grid, workflow, pset = NULL) { } check_workflow(workflow, pset = pset, check_dials = TRUE) - grid <- dials::grid_latin_hypercube(pset, size = grid) + grid <- dials::grid_space_filling(pset, size = grid) grid <- dplyr::distinct(grid) } diff --git a/tests/testthat/_snaps/tune_cluster.md b/tests/testthat/_snaps/tune_cluster.md index 9fa7c69f..90450317 100644 --- a/tests/testthat/_snaps/tune_cluster.md +++ b/tests/testthat/_snaps/tune_cluster.md @@ -79,10 +79,10 @@ 1 }, save_pred = TRUE)) Message - x Fold1: preprocessor 1/1: Error in `get_all_predictors()`: - ! The following predi... - x Fold2: preprocessor 1/1: Error in `get_all_predictors()`: - ! The following predi... + x Fold1: preprocessor 1/1: Error in `hardhat::mold()`: + ! The following predictor ... + x Fold2: preprocessor 1/1: Error in `hardhat::mold()`: + ! The following predictor ... Condition Warning: All models failed. See the `.notes` column. @@ -118,8 +118,8 @@ # A tibble: 2 x 4 splits id .metrics .notes - 1 Fold1 - 2 Fold2 + 1 Fold1 + 2 Fold2 # select_best() and show_best() works