Skip to content

Commit 3b77b68

Browse files
committed
Rename parameter classes for consistency: update 'Params' to 'Config' in Resampler subclasses
1 parent cfb769d commit 3b77b68

File tree

2 files changed

+64
-64
lines changed

2 files changed

+64
-64
lines changed

R/04_S7_Resampler.R

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,16 @@ method(desc_alt, ResamplerConfig) <- function(x) {
9595
)
9696
} # /rtemis::desc.ResamplerConfig
9797

98-
# KFoldParams ----
99-
#' @title KFoldParams
98+
# KFoldConfig ----
99+
#' @title KFoldConfig
100100
#'
101101
#' @description
102102
#' ResamplerConfig subclass for k-fold resampling.
103103
#'
104104
#' @author EDG
105105
#' @noRd
106-
KFoldParams <- new_class(
107-
name = "KFoldParams",
106+
KFoldConfig <- new_class(
107+
name = "KFoldConfig",
108108
parent = ResamplerConfig,
109109
properties = list(
110110
stratify_var = class_character | NULL,
@@ -124,18 +124,18 @@ KFoldParams <- new_class(
124124
seed = seed
125125
)
126126
}
127-
) # /KFoldParams
127+
) # /KFoldConfig
128128

129-
# StratSubParams ----
130-
#' @title StratSubParams
129+
# StratSubConfig ----
130+
#' @title StratSubConfig
131131
#'
132132
#' @description
133133
#' ResamplerConfig subclass for stratified subsampling.
134134
#'
135135
#' @author EDG
136136
#' @noRd
137-
StratSubParams <- new_class(
138-
name = "StratSubParams",
137+
StratSubConfig <- new_class(
138+
name = "StratSubConfig",
139139
parent = ResamplerConfig,
140140
properties = list(
141141
n = scalar_int_pos,
@@ -165,18 +165,18 @@ StratSubParams <- new_class(
165165
seed = seed
166166
)
167167
}
168-
) # /StratSubParams
168+
) # /StratSubConfig
169169

170-
# StratBootParams ----
171-
#' @title StratBootParams
170+
# StratBootConfig ----
171+
#' @title StratBootConfig
172172
#'
173173
#' @description
174174
#' ResamplerConfig subclass for stratified bootstrapping.
175175
#'
176176
#' @author EDG
177177
#' @noRd
178-
StratBootParams <- new_class(
179-
name = "StratBootParams",
178+
StratBootConfig <- new_class(
179+
name = "StratBootConfig",
180180
parent = ResamplerConfig,
181181
properties = list(
182182
stratify_var = class_character | NULL,
@@ -208,18 +208,18 @@ StratBootParams <- new_class(
208208
seed = seed
209209
)
210210
}
211-
) # /StratBootParams
211+
) # /StratBootConfig
212212

213-
# BootstrapParams ----
214-
#' @title BootstrapParams
213+
# BootstrapConfig ----
214+
#' @title BootstrapConfig
215215
#'
216216
#' @description
217217
#' ResamplerConfig subclass for bootstrap resampling.
218218
#'
219219
#' @author EDG
220220
#' @noRd
221-
BootstrapParams <- new_class(
222-
name = "BootstrapParams",
221+
BootstrapConfig <- new_class(
222+
name = "BootstrapConfig",
223223
parent = ResamplerConfig,
224224
properties = list(
225225
id_strat = class_vector | NULL,
@@ -235,18 +235,18 @@ BootstrapParams <- new_class(
235235
seed = seed
236236
)
237237
}
238-
) # /BootstrapParams
238+
) # /BootstrapConfig
239239

240-
# LOOCVParams ----
241-
#' @title LOOCVParams
240+
# LOOCVConfig ----
241+
#' @title LOOCVConfig
242242
#'
243243
#' @description
244244
#' ResamplerConfig subclass for leave-one-out cross-validation.
245245
#'
246246
#' @author EDG
247247
#' @noRd
248-
LOOCVParams <- new_class(
249-
name = "LOOCVParams",
248+
LOOCVConfig <- new_class(
249+
name = "LOOCVConfig",
250250
parent = ResamplerConfig,
251251
constructor = function(n) {
252252
new_object(
@@ -256,18 +256,18 @@ LOOCVParams <- new_class(
256256
)
257257
)
258258
}
259-
) # /LOOCVParams
259+
) # /LOOCVConfig
260260

261-
# CustomParams ----
262-
#' @title CustomParams
261+
# CustomConfig ----
262+
#' @title CustomConfig
263263
#'
264264
#' @description
265265
#' ResamplerConfig subclass for custom resampling.
266266
#'
267267
#' @author EDG
268268
#' @noRd
269-
CustomParams <- new_class(
270-
name = "CustomParams",
269+
CustomConfig <- new_class(
270+
name = "CustomConfig",
271271
parent = ResamplerConfig,
272272
constructor = function(n) {
273273
new_object(
@@ -277,7 +277,7 @@ CustomParams <- new_class(
277277
)
278278
)
279279
}
280-
) # /CustomParams
280+
) # /CustomConfig
281281

282282
# setup_Resampler() ----
283283
#' Setup Resampler
@@ -324,15 +324,15 @@ setup_Resampler <- function(
324324
seed <- clean_int(seed)
325325

326326
if (type == "KFold") {
327-
KFoldParams(
327+
KFoldConfig(
328328
n = n_resamples,
329329
stratify_var = stratify_var,
330330
strat_n_bins = strat_n_bins,
331331
id_strat = id_strat,
332332
seed = seed
333333
)
334334
} else if (type == "StratSub") {
335-
StratSubParams(
335+
StratSubConfig(
336336
n = n_resamples,
337337
train_p = train_p,
338338
stratify_var = stratify_var,
@@ -341,7 +341,7 @@ setup_Resampler <- function(
341341
seed = seed
342342
)
343343
} else if (type == "StratBoot") {
344-
StratBootParams(
344+
StratBootConfig(
345345
n = n_resamples,
346346
train_p = train_p,
347347
stratify_var = stratify_var,
@@ -351,13 +351,13 @@ setup_Resampler <- function(
351351
seed = seed
352352
)
353353
} else if (type == "Bootstrap") {
354-
BootstrapParams(
354+
BootstrapConfig(
355355
n = n_resamples,
356356
id_strat = id_strat,
357357
seed = seed
358358
)
359359
} else if (type == "LOOCV") {
360-
LOOCVParams(
360+
LOOCVConfig(
361361
n = NA_integer_
362362
)
363363
} else {

tests/testthat/test_Resampler.R

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@
44

55
# library(testthat)
66

7-
# StratSubParams ----
8-
test_that("StratSubParams succeeds", {
9-
rsp <- StratSubParams(
7+
# StratSubConfig ----
8+
test_that("StratSubConfig succeeds", {
9+
rsp <- StratSubConfig(
1010
n = 10L,
1111
stratify_var = NULL,
1212
train_p = .75,
1313
strat_n_bins = 4L,
1414
id_strat = NULL,
1515
seed = NULL
1616
)
17-
expect_s7_class(rsp, StratSubParams)
17+
expect_s7_class(rsp, StratSubConfig)
1818
})
1919

20-
# KFoldParams ----
21-
test_that("KFoldParams succeeds", {
22-
rsp <- KFoldParams(
20+
# KFoldConfig ----
21+
test_that("KFoldConfig succeeds", {
22+
rsp <- KFoldConfig(
2323
n = 10L,
2424
stratify_var = NULL,
2525
strat_n_bins = 4L,
2626
id_strat = NULL,
2727
seed = NULL
2828
)
29-
expect_s7_class(rsp, KFoldParams)
29+
expect_s7_class(rsp, KFoldConfig)
3030
})
3131

32-
# BootstrapParams ----
33-
test_that("BootstrapParams succeeds", {
34-
rsp <- BootstrapParams(
32+
# BootstrapConfig ----
33+
test_that("BootstrapConfig succeeds", {
34+
rsp <- BootstrapConfig(
3535
n = 10L,
3636
id_strat = NULL,
3737
seed = NULL
3838
)
39-
expect_s7_class(rsp, BootstrapParams)
39+
expect_s7_class(rsp, BootstrapConfig)
4040
})
4141

42-
# StratBootParams ----
43-
test_that("StratBootParams succeeds", {
44-
rsp <- StratBootParams(
42+
# StratBootConfig ----
43+
test_that("StratBootConfig succeeds", {
44+
rsp <- StratBootConfig(
4545
n = 10L,
4646
stratify_var = NULL,
4747
train_p = .75,
@@ -50,23 +50,23 @@ test_that("StratBootParams succeeds", {
5050
id_strat = NULL,
5151
seed = NULL
5252
)
53-
expect_s7_class(rsp, StratBootParams)
53+
expect_s7_class(rsp, StratBootConfig)
5454
})
5555

56-
# LOOCVParams ----
57-
test_that("LOOCVParams succeeds", {
58-
rsp <- LOOCVParams(
56+
# LOOCVConfig ----
57+
test_that("LOOCVConfig succeeds", {
58+
rsp <- LOOCVConfig(
5959
n = 10L
6060
)
61-
expect_s7_class(rsp, LOOCVParams)
61+
expect_s7_class(rsp, LOOCVConfig)
6262
})
6363

64-
# CustomParams ----
65-
test_that("CustomParams succeeds", {
66-
rsp <- CustomParams(
64+
# CustomConfig ----
65+
test_that("CustomConfig succeeds", {
66+
rsp <- CustomConfig(
6767
n = 10L
6868
)
69-
expect_s7_class(rsp, CustomParams)
69+
expect_s7_class(rsp, CustomConfig)
7070
})
7171

7272
# setup_Resampler() defaults ----
@@ -78,19 +78,19 @@ test_that("setup_Resampler() succeeds", {
7878
# setup_Resampler() kfold ----
7979
test_that("setup_Resampler() kfold succeeds", {
8080
rsp <- setup_Resampler(type = "KFold")
81-
expect_s7_class(rsp, KFoldParams)
81+
expect_s7_class(rsp, KFoldConfig)
8282
})
8383

8484
# setup_Resampler() strat_sub ----
8585
test_that("setup_Resampler() strat_sub succeeds", {
8686
rsp <- setup_Resampler(type = "StratSub")
87-
expect_s7_class(rsp, StratSubParams)
87+
expect_s7_class(rsp, StratSubConfig)
8888
})
8989

9090
# setup_Resampler() strat_boot ----
9191
test_that("setup_Resampler() strat_boot succeeds", {
9292
rsp <- setup_Resampler(type = "StratBoot")
93-
expect_s7_class(rsp, StratBootParams)
93+
expect_s7_class(rsp, StratBootConfig)
9494
})
9595

9696
test_that("setup_Resampler() strat_boot fails with invalid train_p", {
@@ -102,13 +102,13 @@ test_that("setup_Resampler() strat_boot fails with invalid train_p", {
102102
# setup_Resampler() bootstrap ----
103103
test_that("setup_Resampler() bootstrap succeeds", {
104104
rsp <- setup_Resampler(type = "Bootstrap")
105-
expect_s7_class(rsp, BootstrapParams)
105+
expect_s7_class(rsp, BootstrapConfig)
106106
})
107107

108108
# setup_Resampler() loocv ----
109109
test_that("setup_Resampler() loocv succeeds", {
110110
rsp <- setup_Resampler(type = "LOOCV")
111-
expect_s7_class(rsp, LOOCVParams)
111+
expect_s7_class(rsp, LOOCVConfig)
112112
})
113113

114114
# Resampler ----

0 commit comments

Comments
 (0)