From 7f85a561c3ade216cb3bdbbd20a64bb6d4e29761 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Fri, 1 Dec 2023 20:35:36 +0000 Subject: [PATCH 1/5] no double intercepts thx --- .../test-workflows-parsnip-intercept.R | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 tests/testthat/test-workflows-parsnip-intercept.R diff --git a/tests/testthat/test-workflows-parsnip-intercept.R b/tests/testthat/test-workflows-parsnip-intercept.R new file mode 100644 index 0000000..b0df0e4 --- /dev/null +++ b/tests/testthat/test-workflows-parsnip-intercept.R @@ -0,0 +1,69 @@ +skip_if_not_installed("parsnip", minimum_version = "1.1.1.9004") + +test_that("preprocessing formula doesn't result in extra intercept - xy_xy()", { + wflow_fit <- workflow() %>% + add_formula(mpg ~ cyl + disp + hp) %>% + add_model(linear_reg(penalty = 0.1, engine = "glmnet")) %>% + fit(data = mtcars) + + coef_names <- wflow_fit %>% + extract_fit_engine() %>% + coef() %>% + rownames() + expect_equal(coef_names, c("(Intercept)", "cyl", "disp", "hp")) + + expect_no_error( + predict(wflow_fit, new_data = mtcars) + ) +}) + +test_that("preprocessing formula doesn't result in extra intercept - xy_form()", { + wflow_fit <- workflow() %>% + add_formula(mpg ~ cyl + disp + hp) %>% + add_model(linear_reg(engine = "lm")) %>% + fit(data = mtcars) + + coef_names <- wflow_fit %>% + extract_fit_engine() %>% + coef() %>% + names() + expect_equal(coef_names, c("(Intercept)", "cyl", "disp", "hp")) + + expect_no_error( + predict(wflow_fit, new_data = mtcars) + ) +}) + +test_that("preprocessing formula doesn't result in extra intercept - form_xy()", { + wflow_fit <- workflow() %>% + add_formula(mpg ~ cyl + disp + hp) %>% + add_model(linear_reg(penalty = 0.1, engine = "glmnet"), formula = mpg ~ .) %>% + fit(data = mtcars) + + coef_names <- wflow_fit %>% + extract_fit_engine() %>% + coef() %>% + rownames() + expect_equal(coef_names, c("(Intercept)", "cyl", "disp", "hp")) + + expect_no_error( + predict(wflow_fit, new_data = mtcars) + ) +}) + +test_that("preprocessing formula doesn't result in extra intercept - form_form()", { + wflow_fit <- workflow() %>% + add_formula(mpg ~ cyl + disp + hp) %>% + add_model(linear_reg(engine = "lm"), formula = mpg ~ .) %>% + fit(data = mtcars) + + coef_names <- wflow_fit %>% + extract_fit_engine() %>% + coef() %>% + names() + expect_equal(coef_names, c("(Intercept)", "cyl", "disp", "hp")) + + expect_no_error( + predict(wflow_fit, new_data = mtcars) + ) +}) From ea001922769e9ce2acfa72b83fd1a66adabaffe6 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Fri, 1 Dec 2023 20:35:57 +0000 Subject: [PATCH 2/5] temporarily point to PR branch --- .github/workflows/GH-R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GH-R-CMD-check.yaml b/.github/workflows/GH-R-CMD-check.yaml index 9d2bd51..df83d04 100644 --- a/.github/workflows/GH-R-CMD-check.yaml +++ b/.github/workflows/GH-R-CMD-check.yaml @@ -66,7 +66,7 @@ jobs: try(pak::pkg_install("tidymodels/hardhat")) try(pak::pkg_install("tidymodels/modeldata")) try(pak::pkg_install("tidymodels/multilevelmod")) - try(pak::pkg_install("tidymodels/parsnip")) + try(pak::pkg_install("tidymodels/parsnip#1033")) try(pak::pkg_install("tidymodels/plsmod")) try(pak::pkg_install("tidymodels/poissonreg")) try(pak::pkg_install("tidymodels/recipes")) From 96daac7bbf1d1d3592a7f9844f63a8854c44176e Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Thu, 7 Dec 2023 17:45:04 +0000 Subject: [PATCH 3/5] pr is merged --- .github/workflows/GH-R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/GH-R-CMD-check.yaml b/.github/workflows/GH-R-CMD-check.yaml index df83d04..9d2bd51 100644 --- a/.github/workflows/GH-R-CMD-check.yaml +++ b/.github/workflows/GH-R-CMD-check.yaml @@ -66,7 +66,7 @@ jobs: try(pak::pkg_install("tidymodels/hardhat")) try(pak::pkg_install("tidymodels/modeldata")) try(pak::pkg_install("tidymodels/multilevelmod")) - try(pak::pkg_install("tidymodels/parsnip#1033")) + try(pak::pkg_install("tidymodels/parsnip")) try(pak::pkg_install("tidymodels/plsmod")) try(pak::pkg_install("tidymodels/poissonreg")) try(pak::pkg_install("tidymodels/recipes")) From 0b9a260a46145011bb70da204354a27f4f4cf4cc Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Fri, 8 Dec 2023 22:04:05 +0000 Subject: [PATCH 4/5] let's try this again --- .github/workflows/GH-R-CMD-check.yaml | 2 +- .github/workflows/spark-R-CMD-check.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/GH-R-CMD-check.yaml b/.github/workflows/GH-R-CMD-check.yaml index 9d2bd51..397b3cb 100644 --- a/.github/workflows/GH-R-CMD-check.yaml +++ b/.github/workflows/GH-R-CMD-check.yaml @@ -66,7 +66,7 @@ jobs: try(pak::pkg_install("tidymodels/hardhat")) try(pak::pkg_install("tidymodels/modeldata")) try(pak::pkg_install("tidymodels/multilevelmod")) - try(pak::pkg_install("tidymodels/parsnip")) + try(pak::pkg_install("tidymodels/parsnip#1035")) try(pak::pkg_install("tidymodels/plsmod")) try(pak::pkg_install("tidymodels/poissonreg")) try(pak::pkg_install("tidymodels/recipes")) diff --git a/.github/workflows/spark-R-CMD-check.yaml b/.github/workflows/spark-R-CMD-check.yaml index 60782ea..ae5becd 100644 --- a/.github/workflows/spark-R-CMD-check.yaml +++ b/.github/workflows/spark-R-CMD-check.yaml @@ -68,7 +68,7 @@ jobs: - name: Install devel versions run: | - try(pak::pkg_install("tidymodels/parsnip")) + try(pak::pkg_install("tidymodels/parsnip#1035")) shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2 From f5b4e5187e30facf891f6522beafae7ae124d787 Mon Sep 17 00:00:00 2001 From: Hannah Frick Date: Mon, 11 Dec 2023 09:57:09 +0000 Subject: [PATCH 5/5] PR has been merged --- .github/workflows/GH-R-CMD-check.yaml | 2 +- .github/workflows/spark-R-CMD-check.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/GH-R-CMD-check.yaml b/.github/workflows/GH-R-CMD-check.yaml index 397b3cb..9d2bd51 100644 --- a/.github/workflows/GH-R-CMD-check.yaml +++ b/.github/workflows/GH-R-CMD-check.yaml @@ -66,7 +66,7 @@ jobs: try(pak::pkg_install("tidymodels/hardhat")) try(pak::pkg_install("tidymodels/modeldata")) try(pak::pkg_install("tidymodels/multilevelmod")) - try(pak::pkg_install("tidymodels/parsnip#1035")) + try(pak::pkg_install("tidymodels/parsnip")) try(pak::pkg_install("tidymodels/plsmod")) try(pak::pkg_install("tidymodels/poissonreg")) try(pak::pkg_install("tidymodels/recipes")) diff --git a/.github/workflows/spark-R-CMD-check.yaml b/.github/workflows/spark-R-CMD-check.yaml index ae5becd..60782ea 100644 --- a/.github/workflows/spark-R-CMD-check.yaml +++ b/.github/workflows/spark-R-CMD-check.yaml @@ -68,7 +68,7 @@ jobs: - name: Install devel versions run: | - try(pak::pkg_install("tidymodels/parsnip#1035")) + try(pak::pkg_install("tidymodels/parsnip")) shell: Rscript {0} - uses: r-lib/actions/check-r-package@v2