@@ -5,8 +5,6 @@ library(dplyr)
55
66context(" varying parameters" )
77
8- load(test_path(" recipes_examples.RData" ))
9-
108test_that(' main parsnip arguments' , {
119
1210 mod_1 <- rand_forest() %> %
@@ -94,49 +92,6 @@ test_that('other parsnip arguments', {
9492 expect_equal(other_4 , exp_4 )
9593})
9694
97-
98- test_that(' recipe parameters' , {
99-
100- # un-randomify the id names
101- rec_1_id <- rec_1
102- rec_1_id $ steps [[1 ]]$ id <- " center_1"
103- rec_1_id $ steps [[2 ]]$ id <- " knnimpute_1"
104- rec_1_id $ steps [[3 ]]$ id <- " pca_1"
105-
106- rec_res_1 <- varying_args(rec_1_id )
107-
108- exp_1 <- tibble(
109- name = c(" K" , " num" , " threshold" , " options" ),
110- varying = c(TRUE , TRUE , FALSE , FALSE ),
111- id = c(" knnimpute_1" , rep(" pca_1" , 3 )),
112- type = rep(" step" , 4 )
113- )
114-
115- expect_equal(rec_res_1 , exp_1 )
116-
117- # un-randomify the id names
118- rec_3_id <- rec_3
119- rec_3_id $ steps [[1 ]]$ id <- " center_1"
120- rec_3_id $ steps [[2 ]]$ id <- " knnimpute_1"
121- rec_3_id $ steps [[3 ]]$ id <- " pca_1"
122-
123- rec_res_3 <- varying_args(rec_3_id )
124- exp_3 <- exp_1
125- exp_3 $ varying <- FALSE
126- expect_equal(rec_res_3 , exp_3 )
127-
128- rec_res_4 <- varying_args(rec_4 )
129-
130- exp_4 <- tibble(
131- name = character (),
132- varying = logical (),
133- id = character (),
134- type = character ()
135- )
136-
137- expect_equal(rec_res_4 , exp_4 )
138- })
139-
14095test_that(" empty lists return FALSE - #131" , {
14196 expect_equal(
14297 parsnip ::: find_varying(list ()),
@@ -164,33 +119,3 @@ test_that("varying() deeply nested in calls can be located - #134", {
164119 TRUE
165120 )
166121})
167-
168- test_that(" recipe steps with non-varying args error if specified as varying()" , {
169-
170- rec_bad_varying <- rec_1
171- rec_bad_varying $ steps [[1 ]]$ skip <- varying()
172-
173- expect_error(
174- varying_args(rec_bad_varying ),
175- " The following argument for a recipe step of type 'step_center' is not allowed to vary: 'skip'."
176- )
177- })
178-
179- test_that(" `full = FALSE` returns only varying arguments" , {
180-
181- x_spec <- rand_forest(min_n = varying()) %> %
182- set_engine(" ranger" , sample.fraction = varying())
183-
184- x_rec <- rec_1
185-
186- expect_equal(
187- varying_args(x_spec , full = FALSE )$ name ,
188- c(" min_n" , " sample.fraction" )
189- )
190-
191- expect_equal(
192- varying_args(x_rec , full = FALSE )$ name ,
193- c(" K" , " num" )
194- )
195-
196- })
0 commit comments