File tree Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Expand file tree Collapse file tree 3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -74,6 +74,24 @@ extract_fit_engine.model_fit <- function(x, ...) {
7474# ' @export
7575# ' @rdname extract-parsnip
7676extract_parameter_set_dials.model_spec <- function (x , ... ) {
77+ if (! spec_is_loaded(
78+ cls = class(x )[1 ],
79+ engine = x $ engine ,
80+ user_specified_engine = x $ user_specified_engine ,
81+ mode = x $ mode ,
82+ user_specified_mode = x $ user_specified_mode
83+ )) {
84+ prompt_missing_implementation(
85+ cls = class(x )[1 ],
86+ engine = x $ engine ,
87+ user_specified_engine = x $ user_specified_engine ,
88+ mode = x $ mode ,
89+ user_specified_mode = x $ user_specified_mode ,
90+ prompt = cli :: cli_abort ,
91+ call = NULL
92+ )
93+ }
94+
7795 all_args <- generics :: tunable(x )
7896 tuning_param <- generics :: tune_args(x )
7997
Original file line number Diff line number Diff line change 1+ # extract parameter set from model with no loaded implementation
2+
3+ Code
4+ extract_parameter_set_dials(bt_mod)
5+ Condition
6+ Error:
7+ ! parsnip could not locate an implementation for `bag_tree` regression model specifications.
8+ i The parsnip extension package baguette implements support for this specification.
9+ i Please install (if needed) and load to continue.
10+
11+ ---
12+
13+ Code
14+ extract_parameter_dials(bt_mod, parameter = "min_n")
15+ Condition
16+ Error:
17+ ! parsnip could not locate an implementation for `bag_tree` regression model specifications.
18+ i The parsnip extension package baguette implements support for this specification.
19+ i Please install (if needed) and load to continue.
20+
Original file line number Diff line number Diff line change @@ -50,6 +50,14 @@ test_that('extract parameter set from model with main and engine parameters', {
5050 expect_equal(c5_info $ object [[2 ]], NA )
5151})
5252
53+ test_that(' extract parameter set from model with no loaded implementation' , {
54+ bt_mod <- bag_tree(min_n = tune()) %> %
55+ set_mode(" regression" )
56+
57+ expect_snapshot(error = TRUE , extract_parameter_set_dials(bt_mod ))
58+ expect_snapshot(error = TRUE , extract_parameter_dials(bt_mod , parameter = " min_n" ))
59+ })
60+
5361# ------------------------------------------------------------------------------
5462
5563test_that(' extract single parameter from model with no parameters' , {
You can’t perform that action at this time.
0 commit comments