From 74f2bfd52982706d7b43866064dbfa03bee96212 Mon Sep 17 00:00:00 2001 From: simonpcouch Date: Thu, 15 Sep 2022 15:23:25 -0400 Subject: [PATCH] unexport checking helpers --- NAMESPACE | 3 -- R/misc.R | 80 +++++++++++++++++++------------------------ man/add_on_exports.Rd | 66 ----------------------------------- 3 files changed, 35 insertions(+), 114 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 1158e37fe..319459eb1 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -247,7 +247,6 @@ export(predict_time) export(predict_time.model_fit) export(prepare_data) export(print_model_spec) -export(prompt_missing_implementation) export(proportional_hazards) export(rand_forest) export(repair_call) @@ -273,8 +272,6 @@ export(show_call) export(show_engines) export(show_fit) export(show_model_info) -export(spec_is_loaded) -export(spec_is_possible) export(stan_conf_int) export(surv_reg) export(survival_reg) diff --git a/R/misc.R b/R/misc.R index 744cabf37..3414d92de 100644 --- a/R/misc.R +++ b/R/misc.R @@ -54,43 +54,39 @@ mode_filter_condition <- function(mode, user_specified_mode) { rlang::quo(mode == !!mode) } -#' @section Model Specification Checking: -#' -#' The helpers `spec_is_possible()`, `spec_is_loaded()`, and -#' `prompt_missing_implementation()` provide tooling for checking -#' model specifications. In addition to the `spec`, `engine`, and `mode` -#' arguments, the functions take arguments `user_specified_engine` and -#' `user_specified_mode`, denoting whether the user themselves has -#' specified the engine or mode, respectively. -#' -#' `spec_is_possible()` checks against the union of -#' -#' * the current parsnip model environment and -#' * the `model_info_table` of "pre-registered" model specifications -#' -#' to determine whether a model is well-specified. See -#' `parsnip:::read_model_info_table()` for this table. -#' -#' `spec_is_loaded()` checks only against the current parsnip model environment. -#' -#' `spec_is_possible()` is executed automatically on `new_model_spec()`, -#' `set_mode()`, and `set_engine()`, and `spec_is_loaded()` is executed -#' automatically in `print.model_spec()`, among other places. `spec_is_possible()` -#' should be used when a model specification is still "in progress" of being -#' specified, while `spec_is_loaded` should only be called when parsnip or an -#' extension receives some indication that the user is "done" specifying a model -#' specification: at print, fit, addition to a workflow, or `extract_*()`, for -#' example. -#' -#' When `spec_is_loaded()` is `FALSE`, the `prompt_missing_implementation()` -#' helper will construct an informative message to prompt users to load or -#' install needed packages. It's `prompt` argument refers to the prompting -#' function to use, usually [cli::cli_inform] or [cli::cli_abort], and the -#' ellipses are passed to that function. -#' -#' @export -#' @keywords internal -#' @rdname add_on_exports +# Model Specification Checking: +# +# The helpers `spec_is_possible()`, `spec_is_loaded()`, and +# `prompt_missing_implementation()` provide tooling for checking +# model specifications. In addition to the `spec`, `engine`, and `mode` +# arguments, the functions take arguments `user_specified_engine` and +# `user_specified_mode`, denoting whether the user themselves has +# specified the engine or mode, respectively. +# +# `spec_is_possible()` checks against the union of +# +# * the current parsnip model environment and +# * the `model_info_table` of "pre-registered" model specifications +# +# to determine whether a model is well-specified. See +# `parsnip:::read_model_info_table()` for this table. +# +# `spec_is_loaded()` checks only against the current parsnip model environment. +# +# `spec_is_possible()` is executed automatically on `new_model_spec()`, +# `set_mode()`, and `set_engine()`, and `spec_is_loaded()` is executed +# automatically in `print.model_spec()`, among other places. `spec_is_possible()` +# should be used when a model specification is still "in progress" of being +# specified, while `spec_is_loaded` should only be called when parsnip or an +# extension receives some indication that the user is "done" specifying a model +# specification: at print, fit, addition to a workflow, or `extract_*()`, for +# example. +# +# When `spec_is_loaded()` is `FALSE`, the `prompt_missing_implementation()` +# helper will construct an informative message to prompt users to load or +# install needed packages. It's `prompt` argument refers to the prompting +# function to use, usually [cli::cli_inform] or [cli::cli_abort], and the +# ellipses are passed to that function. spec_is_possible <- function(spec, engine = spec$engine, user_specified_engine = spec$user_specified_engine, @@ -119,10 +115,7 @@ spec_is_possible <- function(spec, return(nrow(possibilities) > 0) } -# see ?add_on_exports for more information on usage -#' @export -#' @keywords internal -#' @rdname add_on_exports +# see notes above spec_is_possible for more information on usage spec_is_loaded <- function(spec, engine = spec$engine, user_specified_engine = spec$user_specified_engine, @@ -160,10 +153,7 @@ is_printable_spec <- function(x) { # if there's a "pre-registered" extension supporting that setup, # nudge the user to install/load it. # -# see ?add_on_exports for more information on usage -#' @export -#' @keywords internal -#' @rdname add_on_exports +# see notes above spec_is_possible for more information on usage prompt_missing_implementation <- function(spec, engine = spec$engine, user_specified_engine = spec$user_specified_engine, diff --git a/man/add_on_exports.Rd b/man/add_on_exports.Rd index cacd96807..86e840ebd 100644 --- a/man/add_on_exports.Rd +++ b/man/add_on_exports.Rd @@ -3,9 +3,6 @@ % R/varying.R \name{null_value} \alias{null_value} -\alias{spec_is_possible} -\alias{spec_is_loaded} -\alias{prompt_missing_implementation} \alias{show_fit} \alias{update_dot_check} \alias{new_model_spec} @@ -19,32 +16,6 @@ \usage{ null_value(x) -spec_is_possible( - spec, - engine = spec$engine, - user_specified_engine = spec$user_specified_engine, - mode = spec$mode, - user_specified_mode = spec$user_specified_mode -) - -spec_is_loaded( - spec, - engine = spec$engine, - user_specified_engine = spec$user_specified_engine, - mode = spec$mode, - user_specified_mode = spec$user_specified_mode -) - -prompt_missing_implementation( - spec, - engine = spec$engine, - user_specified_engine = spec$user_specified_engine, - mode = spec$mode, - user_specified_mode = spec$user_specified_mode, - prompt, - ... -) - show_fit(model, eng) update_dot_check(...) @@ -76,41 +47,4 @@ is_varying(x) These functions are helpful when creating new packages that will register new model specifications. } -\section{Model Specification Checking}{ - - -The helpers \code{spec_is_possible()}, \code{spec_is_loaded()}, and -\code{prompt_missing_implementation()} provide tooling for checking -model specifications. In addition to the \code{spec}, \code{engine}, and \code{mode} -arguments, the functions take arguments \code{user_specified_engine} and -\code{user_specified_mode}, denoting whether the user themselves has -specified the engine or mode, respectively. - -\code{spec_is_possible()} checks against the union of -\itemize{ -\item the current parsnip model environment and -\item the \code{model_info_table} of "pre-registered" model specifications -} - -to determine whether a model is well-specified. See -\code{parsnip:::read_model_info_table()} for this table. - -\code{spec_is_loaded()} checks only against the current parsnip model environment. - -\code{spec_is_possible()} is executed automatically on \code{new_model_spec()}, -\code{set_mode()}, and \code{set_engine()}, and \code{spec_is_loaded()} is executed -automatically in \code{print.model_spec()}, among other places. \code{spec_is_possible()} -should be used when a model specification is still "in progress" of being -specified, while \code{spec_is_loaded} should only be called when parsnip or an -extension receives some indication that the user is "done" specifying a model -specification: at print, fit, addition to a workflow, or \verb{extract_*()}, for -example. - -When \code{spec_is_loaded()} is \code{FALSE}, the \code{prompt_missing_implementation()} -helper will construct an informative message to prompt users to load or -install needed packages. It's \code{prompt} argument refers to the prompting -function to use, usually \link[cli:cli_abort]{cli::cli_inform} or \link[cli:cli_abort]{cli::cli_abort}, and the -ellipses are passed to that function. -} - \keyword{internal}