Skip to content

Commit 849e981

Browse files
committed
newly exported functions used for external packages
1 parent 2e5d3fa commit 849e981

File tree

7 files changed

+72
-6
lines changed

7 files changed

+72
-6
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Imports:
3131
prettyunits,
3232
vctrs (>= 0.2.0)
3333
Roxygen: list(markdown = TRUE)
34-
RoxygenNote: 7.0.1.9000
34+
RoxygenNote: 7.0.2.9000
3535
Suggests:
3636
testthat,
3737
knitr,

NAMESPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ export(C5.0_train)
9090
export(add_rowindex)
9191
export(boost_tree)
9292
export(check_empty_ellipse)
93+
export(check_final_param)
9394
export(control_parsnip)
9495
export(decision_tree)
9596
export(fit)
@@ -103,6 +104,7 @@ export(get_from_env)
103104
export(get_model_env)
104105
export(get_pred_type)
105106
export(has_multi_predict)
107+
export(is_varying)
106108
export(keras_mlp)
107109
export(linear_reg)
108110
export(logistic_reg)
@@ -114,7 +116,9 @@ export(multi_predict)
114116
export(multi_predict_args)
115117
export(multinom_reg)
116118
export(nearest_neighbor)
119+
export(new_model_spec)
117120
export(null_model)
121+
export(null_value)
118122
export(nullmodel)
119123
export(pred_value_template)
120124
export(predict.model_fit)
@@ -133,12 +137,15 @@ export(set_model_mode)
133137
export(set_new_model)
134138
export(set_pred)
135139
export(show_call)
140+
export(show_fit)
136141
export(show_model_info)
137142
export(surv_reg)
138143
export(svm_poly)
139144
export(svm_rbf)
140145
export(tidy.model_fit)
141146
export(translate)
147+
export(update_dot_check)
148+
export(update_main_parameters)
142149
export(varying)
143150
export(varying_args)
144151
export(xgb_train)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
* `glmnet` was removed as a dependency since the new version depends on 3.6.0 or greater. Keeping it would constrain `parsnip` to that same requirement. All `glmnet` tests are run locally.
1010

11+
* A set of internal functions are now exported. These are helpful when creating a new package that registers new model specifications.
12+
1113
## New Features
1214

1315
* `nnet` was added as an engine to `multinom_reg()` [#209](https://github.com/tidymodels/parsnip/issues/209)

R/arguments.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
#' Functions required for parsnip-adjacent packages
2+
#'
3+
#' These functions are helpful when creating new packages that will register
4+
#' new model specifications.
5+
#' @export
6+
#' @keywords internal
7+
#' @rdname add_on_exports
18
#' @importFrom rlang expr enquos enquo quos is_quosure call2 quo_get_expr ll
29
#' @importFrom rlang abort current_env get_expr is_missing is_null is_symbolic missing_arg
310
null_value <- function(x) {

R/misc.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ is_spark <- function(x)
144144
isTRUE(unname(x$method$fit$func["pkg"] == "sparklyr"))
145145

146146

147+
#' @export
148+
#' @keywords internal
149+
#' @rdname add_on_exports
147150
show_fit <- function(model, eng) {
148151
mod <- translate(x = model, engine = eng)
149152
fit_call <- show_call(mod)
@@ -181,6 +184,9 @@ names0 <- function (num, prefix = "x") {
181184

182185
# ------------------------------------------------------------------------------
183186

187+
#' @export
188+
#' @keywords internal
189+
#' @rdname add_on_exports
184190
update_dot_check <- function(...) {
185191
dots <- enquos(...)
186192
if (length(dots) > 0)
@@ -192,6 +198,9 @@ update_dot_check <- function(...) {
192198

193199
# ------------------------------------------------------------------------------
194200

201+
#' @export
202+
#' @keywords internal
203+
#' @rdname add_on_exports
195204
new_model_spec <- function(cls, args, eng_args, mode, method, engine) {
196205
spec_modes <- rlang::env_get(get_model_env(), paste0(cls, "_modes"))
197206
if (!(mode %in% spec_modes))
@@ -236,6 +245,9 @@ terms_y <- function(x) {
236245

237246
# ------------------------------------------------------------------------------
238247

248+
#' @export
249+
#' @keywords internal
250+
#' @rdname add_on_exports
239251
check_final_param <- function(x) {
240252
if (is.null(x)) {
241253
return(invisible(x))
@@ -256,6 +268,9 @@ check_final_param <- function(x) {
256268
invisible(x)
257269
}
258270

271+
#' @export
272+
#' @keywords internal
273+
#' @rdname add_on_exports
259274
update_main_parameters <- function(args, param) {
260275

261276
if (length(param) == 0) {

R/varying.R

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,18 @@ non_varying_step_arguments <- c(
193193

194194
# helpers ----------------------------------------------------------------------
195195

196+
#' @export
197+
#' @keywords internal
198+
#' @rdname add_on_exports
196199
is_varying <- function(x) {
197-
if(is.null(x)) {
200+
if (is.null(x)) {
198201
res <- FALSE
199202
} else {
200-
res <- if(is_quosure(x))
201-
isTRUE(all.equal(x[[-1]], quote(varying())))
202-
else
203-
isTRUE(all.equal(x, quote(varying())))
203+
if (is_quosure(x)) {
204+
res <- isTRUE(all.equal(x[[-1]], quote(varying())))
205+
} else {
206+
res <- isTRUE(all.equal(x, quote(varying())))
207+
}
204208
}
205209
res
206210
}

man/add_on_exports.Rd

Lines changed: 31 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)