Skip to content

Commit b1aaf45

Browse files
committed
migrate tune:::should_internal_split() -> workflows::should_inner_split()
1 parent 7f2a2c4 commit b1aaf45

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

R/fit.R

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ fit.workflow <- function(object, data, ..., control = control_workflow()) {
5959
abort("`data` must be provided to fit a workflow.")
6060
}
6161

62+
if (should_inner_split(object)) {
63+
# todo: make an inner_split here
64+
TRUE
65+
}
66+
6267
workflow <- object
6368
workflow <- .fit_pre(workflow, data)
6469
workflow <- .fit_model(workflow, control)
@@ -70,6 +75,30 @@ fit.workflow <- function(object, data, ..., control = control_workflow()) {
7075
workflow
7176
}
7277

78+
#' @export
79+
#' @keywords internal
80+
should_inner_split <- function(workflow) {
81+
# todo: test this
82+
has_postprocessor(workflow) && postprocessor_requires_training(workflow)
83+
}
84+
85+
postprocessor_requires_training <- function(workflow) {
86+
# todo: make this based on something that an external contributor
87+
# would be able to hook into rather than hard-coding the calibration
88+
# classes: https://github.com/tidymodels/tune/pull/894/files#r1585259827
89+
tailor <- workflow$post$actions$tailor$tailor
90+
91+
operations_are_calibration <-
92+
vapply(
93+
tailor$operations,
94+
rlang::inherits_any,
95+
logical(1),
96+
c("numeric_calibration", "probability_calibration")
97+
)
98+
99+
any(operations_are_calibration)
100+
}
101+
73102
# ------------------------------------------------------------------------------
74103

75104
#' Internal workflow functions

0 commit comments

Comments
 (0)