Skip to content
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

updates for upstream tailor #249

Merged
merged 3 commits into from
Sep 19, 2024
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 R/post-action-tailor.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
#' library(tailor)
#' library(magrittr)
#'
#' tailor <- tailor("binary")
#' tailor <- tailor()
#' tailor_1 <- adjust_probability_threshold(tailor, .1)
#'
#' workflow <- workflow() %>%
Expand Down
2 changes: 1 addition & 1 deletion man/add_tailor.Rd

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

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/printing.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
Message

-- tailor ----------------------------------------------------------------------
A regression postprocessor with 0 adjustments.
A postprocessor with 0 adjustments.
Output
NA
NA
Expand Down
8 changes: 0 additions & 8 deletions tests/testthat/_snaps/sparsevctrs.md

This file was deleted.

4 changes: 2 additions & 2 deletions tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ test_that(".should_inner_split works", {
add_tailor(
tailor::tailor() %>%
tailor::adjust_numeric_calibration() %>%
tailor::adjust_probability_threshold(.4)
tailor::adjust_numeric_range(lower_limit = 1)
)
))
expect_true(.should_inner_split(
Expand All @@ -213,7 +213,7 @@ test_that(".should_inner_split works", {
add_tailor(
tailor::tailor() %>%
tailor::adjust_numeric_calibration() %>%
tailor::adjust_probability_threshold(.4)
tailor::adjust_numeric_range(lower_limit = 1)
)
))
})
Expand Down
16 changes: 8 additions & 8 deletions tests/testthat/test-post-action-tailor.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
test_that("can add a postprocessor to a workflow", {
post <- tailor::tailor("regression")
post <- tailor::tailor()

workflow <- workflow()
workflow <- add_tailor(workflow, post)
Expand All @@ -12,7 +12,7 @@ test_that("postprocessor is validated", {
})

test_that("cannot add two postprocessors", {
post <- tailor::tailor("regression")
post <- tailor::tailor()

workflow <- workflow()
workflow <- add_tailor(workflow, post)
Expand All @@ -21,7 +21,7 @@ test_that("cannot add two postprocessors", {
})

test_that("remove a postprocessor", {
post <- tailor::tailor("regression")
post <- tailor::tailor()

workflow_no_post <- workflow()
workflow_no_post <- add_formula(workflow_no_post, mpg ~ cyl)
Expand All @@ -33,7 +33,7 @@ test_that("remove a postprocessor", {
})

test_that("remove a postprocessor after postprocessor fit", {
post <- tailor::tailor("regression")
post <- tailor::tailor()

workflow_no_post <- workflow()
workflow_no_post <- add_formula(workflow_no_post, mpg ~ cyl)
Expand All @@ -48,7 +48,7 @@ test_that("remove a postprocessor after postprocessor fit", {
})

test_that("update a postprocessor", {
post <- tailor::tailor("regression")
post <- tailor::tailor()
post2 <- tailor::adjust_numeric_range(post, 0, Inf)

workflow <- workflow()
Expand All @@ -59,7 +59,7 @@ test_that("update a postprocessor", {
})

test_that("update a postprocessor after postprocessor fit", {
post <- tailor::tailor("regression")
post <- tailor::tailor()
post2 <- tailor::adjust_numeric_range(post, 0, Inf)

workflow_no_post <- workflow()
Expand All @@ -86,7 +86,7 @@ test_that("postprocessor fit aligns with manually fitted version (no calibration
dat <- data.frame(y = y, x = y + (y-3)^2)

# construct workflows
post <- tailor::tailor("regression")
post <- tailor::tailor()
post <- tailor::adjust_numeric_range(post, 0, 5)

wflow_simple <- workflow(y ~ ., parsnip::linear_reg())
Expand Down Expand Up @@ -116,7 +116,7 @@ test_that("postprocessor fit aligns with manually fitted version (with calibrati
dat <- data.frame(y = y, x = y + (y-3)^2)

# construct workflows
post <- tailor::tailor("regression")
post <- tailor::tailor()
post <- tailor::adjust_numeric_calibration(post, "linear")

wflow_simple <- workflow(y ~ ., parsnip::linear_reg())
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-printing.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ test_that("can print workflow with case weights, preprocessor, and model", {
})

test_that("can print workflow with postprocessor", {
post <- tailor::tailor("regression")
post <- tailor::tailor()
workflow <- workflow()
workflow <- add_postprocessor(workflow, post)

Expand Down
14 changes: 8 additions & 6 deletions tests/testthat/test-sparsevctrs.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
skip("Sparse vector materialized errors")

test_that("sparse tibble can be passed to `fit() - recipe", {
skip_if_not_installed("glmnet")

hotel_data <- sparse_hotel_rates()
hotel_data <- sparsevctrs::coerce_to_sparse_tibble(hotel_data)
# materialize outcome
hotel_data$avg_price_per_room <- hotel_data$avg_price_per_room[]

withr::local_options("sparsevctrs.verbose_materialize" = 3)

spec <- parsnip::linear_reg(penalty = 0) %>%
Expand All @@ -17,7 +19,7 @@ test_that("sparse tibble can be passed to `fit() - recipe", {
wf_spec <- workflow() %>%
add_recipe(rec) %>%
add_model(spec)

expect_no_error(wf_fit <- fit(wf_spec, hotel_data))
})

Expand All @@ -35,7 +37,7 @@ test_that("sparse tibble can be passed to `fit() - formula", {
wf_spec <- workflow() %>%
add_formula(avg_price_per_room ~ .) %>%
add_model(spec)

expect_snapshot(
error = TRUE,
wf_fit <- fit(wf_spec, hotel_data)
Expand All @@ -49,7 +51,7 @@ test_that("sparse tibble can be passed to `fit() - xy", {
hotel_data <- sparsevctrs::coerce_to_sparse_tibble(hotel_data)
# materialize outcome
hotel_data$avg_price_per_room <- hotel_data$avg_price_per_room[]

withr::local_options("sparsevctrs.verbose_materialize" = 3)

spec <- parsnip::linear_reg(penalty = 0) %>%
Expand All @@ -59,6 +61,6 @@ test_that("sparse tibble can be passed to `fit() - xy", {
wf_spec <- workflow() %>%
add_variables(avg_price_per_room, everything()) %>%
add_model(spec)

expect_no_error(wf_fit <- fit(wf_spec, hotel_data))
})
Loading