Skip to content

newly exported functions used for external packages #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Imports:
prettyunits,
vctrs (>= 0.2.0)
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.0.1.9000
RoxygenNote: 7.0.2.9000
Suggests:
testthat,
knitr,
Expand Down
7 changes: 7 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export(C5.0_train)
export(add_rowindex)
export(boost_tree)
export(check_empty_ellipse)
export(check_final_param)
export(control_parsnip)
export(decision_tree)
export(fit)
Expand All @@ -103,6 +104,7 @@ export(get_from_env)
export(get_model_env)
export(get_pred_type)
export(has_multi_predict)
export(is_varying)
export(keras_mlp)
export(linear_reg)
export(logistic_reg)
Expand All @@ -114,7 +116,9 @@ export(multi_predict)
export(multi_predict_args)
export(multinom_reg)
export(nearest_neighbor)
export(new_model_spec)
export(null_model)
export(null_value)
export(nullmodel)
export(pred_value_template)
export(predict.model_fit)
Expand All @@ -133,12 +137,15 @@ export(set_model_mode)
export(set_new_model)
export(set_pred)
export(show_call)
export(show_fit)
export(show_model_info)
export(surv_reg)
export(svm_poly)
export(svm_rbf)
export(tidy.model_fit)
export(translate)
export(update_dot_check)
export(update_main_parameters)
export(varying)
export(varying_args)
export(xgb_train)
Expand Down
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

* `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.

* A set of internal functions are now exported. These are helpful when creating a new package that registers new model specifications.

## New Features

* `nnet` was added as an engine to `multinom_reg()` [#209](https://github.com/tidymodels/parsnip/issues/209)
Expand Down
7 changes: 7 additions & 0 deletions R/arguments.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
#' Functions required for parsnip-adjacent packages
#'
#' These functions are helpful when creating new packages that will register
#' new model specifications.
#' @export
#' @keywords internal
#' @rdname add_on_exports
#' @importFrom rlang expr enquos enquo quos is_quosure call2 quo_get_expr ll
#' @importFrom rlang abort current_env get_expr is_missing is_null is_symbolic missing_arg
null_value <- function(x) {
Expand Down
15 changes: 15 additions & 0 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ is_spark <- function(x)
isTRUE(unname(x$method$fit$func["pkg"] == "sparklyr"))


#' @export
#' @keywords internal
#' @rdname add_on_exports
show_fit <- function(model, eng) {
mod <- translate(x = model, engine = eng)
fit_call <- show_call(mod)
Expand Down Expand Up @@ -181,6 +184,9 @@ names0 <- function (num, prefix = "x") {

# ------------------------------------------------------------------------------

#' @export
#' @keywords internal
#' @rdname add_on_exports
update_dot_check <- function(...) {
dots <- enquos(...)
if (length(dots) > 0)
Expand All @@ -192,6 +198,9 @@ update_dot_check <- function(...) {

# ------------------------------------------------------------------------------

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

# ------------------------------------------------------------------------------

#' @export
#' @keywords internal
#' @rdname add_on_exports
check_final_param <- function(x) {
if (is.null(x)) {
return(invisible(x))
Expand All @@ -256,6 +268,9 @@ check_final_param <- function(x) {
invisible(x)
}

#' @export
#' @keywords internal
#' @rdname add_on_exports
update_main_parameters <- function(args, param) {

if (length(param) == 0) {
Expand Down
14 changes: 9 additions & 5 deletions R/varying.R
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,18 @@ non_varying_step_arguments <- c(

# helpers ----------------------------------------------------------------------

#' @export
#' @keywords internal
#' @rdname add_on_exports
is_varying <- function(x) {
if(is.null(x)) {
if (is.null(x)) {
res <- FALSE
} else {
res <- if(is_quosure(x))
isTRUE(all.equal(x[[-1]], quote(varying())))
else
isTRUE(all.equal(x, quote(varying())))
if (is_quosure(x)) {
res <- isTRUE(all.equal(x[[-1]], quote(varying())))
} else {
res <- isTRUE(all.equal(x, quote(varying())))
}
}
res
}
Expand Down
31 changes: 31 additions & 0 deletions man/add_on_exports.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.