Skip to content

Commit 3fbc3f8

Browse files
committed
un-exported check_* functions
1 parent 8f8a142 commit 3fbc3f8

File tree

3 files changed

+42
-104
lines changed

3 files changed

+42
-104
lines changed

NAMESPACE

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,7 @@ export(.y)
7979
export(C5.0_train)
8080
export(add_rowindex)
8181
export(boost_tree)
82-
export(check_arg_val)
8382
export(check_empty_ellipse)
84-
export(check_engine_val)
85-
export(check_fit_info)
86-
export(check_func_val)
87-
export(check_mod_val)
88-
export(check_mode_val)
89-
export(check_pkg_val)
90-
export(check_pred_info)
91-
export(check_submodels_val)
9283
export(decision_tree)
9384
export(fit)
9485
export(fit.model_spec)

R/aaa_models.R

Lines changed: 20 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ parsnip$modes <- c("regression", "classification", "unknown")
3030

3131
# ------------------------------------------------------------------------------
3232

33-
#' @rdname check_mod_val
33+
#' @rdname get_model_env
3434
#' @keywords internal
3535
#' @export
3636
pred_types <-
@@ -100,7 +100,14 @@ pred_types <-
100100
#' current_code <- get_model_env()
101101
#' ls(envir = current_code)
102102
#'
103+
#' @keywords internal
103104
#' @export
105+
get_model_env <- function() {
106+
current <- utils::getFromNamespace("parsnip", ns = "parsnip")
107+
# current <- parsnip
108+
current
109+
}
110+
104111
check_mod_val <- function(model, new = FALSE, existence = FALSE) {
105112
if (rlang::is_missing(model) || length(model) != 1)
106113
stop("Please supply a character string for a model name (e.g. `'linear_reg'`)",
@@ -126,58 +133,34 @@ check_mod_val <- function(model, new = FALSE, existence = FALSE) {
126133
invisible(NULL)
127134
}
128135

129-
#' @rdname check_mod_val
130-
#' @keywords internal
131-
#' @export
132-
get_model_env <- function() {
133-
current <- utils::getFromNamespace("parsnip", ns = "parsnip")
134-
# current <- parsnip
135-
current
136-
}
137-
138-
#' @rdname check_mod_val
139-
#' @keywords internal
140-
#' @export
141136
check_mode_val <- function(mode) {
142137
if (rlang::is_missing(mode) || length(mode) != 1)
143138
stop("Please supply a character string for a mode (e.g. `'regression'`)",
144139
call. = FALSE)
145140
invisible(NULL)
146141
}
147142

148-
#' @rdname check_mod_val
149-
#' @keywords internal
150-
#' @export
151143
check_engine_val <- function(eng) {
152144
if (rlang::is_missing(eng) || length(eng) != 1)
153145
stop("Please supply a character string for an engine (e.g. `'lm'`)",
154146
call. = FALSE)
155147
invisible(NULL)
156148
}
157149

158-
#' @rdname check_mod_val
159-
#' @keywords internal
160-
#' @export
161150
check_arg_val <- function(arg) {
162151
if (rlang::is_missing(arg) || length(arg) != 1)
163152
stop("Please supply a character string for the argument",
164153
call. = FALSE)
165154
invisible(NULL)
166155
}
167156

168-
#' @rdname check_mod_val
169-
#' @keywords internal
170-
#' @export
171157
check_submodels_val <- function(has_submodel) {
172158
if (!is.logical(has_submodel) || length(has_submodel) != 1) {
173159
stop("The `submodels` argument should be a single logical.", call. = FALSE)
174160
}
175161
invisible(NULL)
176162
}
177163

178-
#' @rdname check_mod_val
179-
#' @keywords internal
180-
#' @export
181164
check_func_val <- function(func) {
182165
msg <-
183166
paste(
@@ -212,9 +195,6 @@ check_func_val <- function(func) {
212195
invisible(NULL)
213196
}
214197

215-
#' @rdname check_mod_val
216-
#' @keywords internal
217-
#' @export
218198
check_fit_info <- function(fit_obj) {
219199
if (is.null(fit_obj)) {
220200
stop("The `fit` module cannot be NULL.", call. = FALSE)
@@ -246,9 +226,6 @@ check_fit_info <- function(fit_obj) {
246226
invisible(NULL)
247227
}
248228

249-
#' @rdname check_mod_val
250-
#' @keywords internal
251-
#' @export
252229
check_pred_info <- function(pred_obj, type) {
253230
if (all(type != pred_types)) {
254231
stop("The prediction type should be one of: ",
@@ -281,9 +258,6 @@ check_pred_info <- function(pred_obj, type) {
281258
invisible(NULL)
282259
}
283260

284-
#' @rdname check_mod_val
285-
#' @keywords internal
286-
#' @export
287261
check_pkg_val <- function(pkg) {
288262
if (rlang::is_missing(pkg) || length(pkg) != 1 || !is.character(pkg))
289263
stop("Please supply a single character vale for the package name",
@@ -293,7 +267,7 @@ check_pkg_val <- function(pkg) {
293267

294268
# ------------------------------------------------------------------------------
295269

296-
#' @rdname check_mod_val
270+
#' @rdname get_model_env
297271
#' @keywords internal
298272
#' @export
299273
set_new_model <- function(model) {
@@ -331,7 +305,7 @@ set_new_model <- function(model) {
331305

332306
# ------------------------------------------------------------------------------
333307

334-
#' @rdname check_mod_val
308+
#' @rdname get_model_env
335309
#' @keywords internal
336310
#' @export
337311
set_model_mode <- function(model, mode) {
@@ -351,7 +325,7 @@ set_model_mode <- function(model, mode) {
351325

352326
# ------------------------------------------------------------------------------
353327

354-
#' @rdname check_mod_val
328+
#' @rdname get_model_env
355329
#' @keywords internal
356330
#' @export
357331
set_model_engine <- function(model, mode, eng) {
@@ -376,7 +350,7 @@ set_model_engine <- function(model, mode, eng) {
376350

377351
# ------------------------------------------------------------------------------
378352

379-
#' @rdname check_mod_val
353+
#' @rdname get_model_env
380354
#' @keywords internal
381355
#' @export
382356
set_model_arg <- function(model, eng, parsnip, original, func, has_submodel) {
@@ -425,7 +399,7 @@ set_model_arg <- function(model, eng, parsnip, original, func, has_submodel) {
425399

426400
# ------------------------------------------------------------------------------
427401

428-
#' @rdname check_mod_val
402+
#' @rdname get_model_env
429403
#' @keywords internal
430404
#' @export
431405
set_dependency <- function(model, eng, pkg) {
@@ -468,7 +442,7 @@ set_dependency <- function(model, eng, pkg) {
468442
invisible(NULL)
469443
}
470444

471-
#' @rdname check_mod_val
445+
#' @rdname get_model_env
472446
#' @keywords internal
473447
#' @export
474448
get_dependency <- function(model) {
@@ -483,7 +457,7 @@ get_dependency <- function(model) {
483457

484458
# ------------------------------------------------------------------------------
485459

486-
#' @rdname check_mod_val
460+
#' @rdname get_model_env
487461
#' @keywords internal
488462
#' @export
489463
set_fit <- function(model, mode, eng, value) {
@@ -534,7 +508,7 @@ set_fit <- function(model, mode, eng, value) {
534508
invisible(NULL)
535509
}
536510

537-
#' @rdname check_mod_val
511+
#' @rdname get_model_env
538512
#' @keywords internal
539513
#' @export
540514
get_fit <- function(model) {
@@ -548,7 +522,7 @@ get_fit <- function(model) {
548522

549523
# ------------------------------------------------------------------------------
550524

551-
#' @rdname check_mod_val
525+
#' @rdname get_model_env
552526
#' @keywords internal
553527
#' @export
554528
set_pred <- function(model, mode, eng, type, value) {
@@ -600,7 +574,7 @@ set_pred <- function(model, mode, eng, type, value) {
600574
invisible(NULL)
601575
}
602576

603-
#' @rdname check_mod_val
577+
#' @rdname get_model_env
604578
#' @keywords internal
605579
#' @export
606580
get_pred_type <- function(model, type) {
@@ -619,7 +593,7 @@ get_pred_type <- function(model, type) {
619593

620594
# ------------------------------------------------------------------------------
621595

622-
#' @rdname check_mod_val
596+
#' @rdname get_model_env
623597
#' @keywords internal
624598
#' @export
625599
show_model_info <- function(model) {
@@ -712,7 +686,7 @@ show_model_info <- function(model) {
712686
invisible(NULL)
713687
}
714688

715-
#' @rdname check_mod_val
689+
#' @rdname get_model_env
716690
#' @keywords internal
717691
#' @export
718692
get_from_env <- function(items) {
Lines changed: 22 additions & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)