Skip to content

Commit 21fc519

Browse files
authored
read_model_info_table() only once (#910)
1 parent 815828f commit 21fc519

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

R/aaa_models.R

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,8 @@ pred_types <-
3737

3838
# ------------------------------------------------------------------------------
3939

40-
read_model_info_table <- function() {
41-
model_info_table <-
42-
utils::read.delim(system.file("models.tsv", package = "parsnip"))
43-
44-
model_info_table
45-
}
40+
model_info_table <-
41+
utils::read.delim(system.file("models.tsv", package = "parsnip"))
4642

4743
# ------------------------------------------------------------------------------
4844

@@ -228,7 +224,7 @@ check_spec_mode_engine_val <- function(cls, eng, mode, call = caller_env()) {
228224
# are contained in a different package
229225
model_info_parsnip_only <-
230226
dplyr::inner_join(
231-
read_model_info_table() %>% dplyr::filter(is.na(pkg)) %>% dplyr::select(-pkg),
227+
model_info_table %>% dplyr::filter(is.na(pkg)) %>% dplyr::select(-pkg),
232228
model_info %>% dplyr::mutate(model = cls),
233229
by = c("model", "engine", "mode")
234230
)

R/misc.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mode_filter_condition <- function(mode, user_specified_mode) {
6969
#' * the `model_info_table` of "pre-registered" model specifications
7070
#'
7171
#' to determine whether a model is well-specified. See
72-
#' `parsnip:::read_model_info_table()` for this table.
72+
#' `parsnip:::model_info_table` for this table.
7373
#'
7474
#' `spec_is_loaded()` checks only against the current parsnip model environment.
7575
#'
@@ -99,7 +99,7 @@ spec_is_possible <- function(spec,
9999

100100
all_model_info <-
101101
dplyr::full_join(
102-
read_model_info_table(),
102+
model_info_table,
103103
rlang::env_get(get_model_env(), cls) %>% dplyr::mutate(model = cls),
104104
by = c("model", "engine", "mode")
105105
)
@@ -183,7 +183,7 @@ prompt_missing_implementation <- function(spec,
183183
}
184184

185185
all <-
186-
read_model_info_table() %>%
186+
model_info_table %>%
187187
dplyr::filter(model == cls, !!mode_condition, !!engine_condition, !is.na(pkg)) %>%
188188
dplyr::select(-model)
189189

man/extension-check-helpers.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)