diff --git a/DESCRIPTION b/DESCRIPTION index d9c46830b..8ff97c42a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,10 @@ Package: parsnip -Version: 0.0.3.9000 +Version: 0.0.3.1 Title: A Common API to Modeling and Analysis Functions Description: A common interface is provided to allow users to specify a model without having to remember the different argument names across different functions or computational engines (e.g. 'R', 'Spark', 'Stan', etc). Authors@R: c( - person("Max", "Kuhn", , "max@rstudio.com", c("aut", "cre")), - person("Davis", "Vaughan", , "davis@rstudio.com", c("aut")), + person(given = "Max", family = "Kuhn", email = "max@rstudio.com", role = c("aut", "cre")), + person(given = "Davis", family = "Vaughan", email = "davis@rstudio.com", role = c("aut")), person("RStudio", role = "cph")) Maintainer: Max Kuhn URL: https://tidymodels.github.io/parsnip diff --git a/NEWS.md b/NEWS.md index 024f4f38d..b125323ca 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,7 @@ -# parsnip 0.0.3.9000 +# parsnip 0.0.3.1 + +Test case update due to CRAN running extra tests [(#202)](https://github.com/tidymodels/parsnip/issues/202) + # parsnip 0.0.3 diff --git a/R/fit.R b/R/fit.R index 1cb32f300..67a2f2e9a 100644 --- a/R/fit.R +++ b/R/fit.R @@ -94,6 +94,9 @@ fit.model_spec <- control = fit_control(), ... ) { + if (object$mode == "unknown") { + stop("Please set the mode in the model specification.", call. = FALSE) + } dots <- quos(...) if (is.null(object$engine)) { eng_vals <- possible_engines(object) @@ -183,6 +186,7 @@ fit_xy.model_spec <- control = fit_control(), ... ) { + object <- check_mode(object, levels(y)) dots <- quos(...) if (is.null(object$engine)) { eng_vals <- possible_engines(object) diff --git a/tests/testthat/test_aaaa.R b/tests/testthat/test_aaaa.R index 4bc446c0c..78ae245aa 100644 --- a/tests/testthat/test_aaaa.R +++ b/tests/testthat/test_aaaa.R @@ -4,7 +4,7 @@ library(testthat) -context("setting keras environment\n") +context("setting keras environment") Sys.setenv(TF_CPP_MIN_LOG_LEVEL = '3') -try(keras:::backend(), silent = TRUE) +k_bk <- try(keras:::backend(), silent = TRUE) diff --git a/tests/testthat/test_fit_interfaces.R b/tests/testthat/test_fit_interfaces.R index c06a8b537..be0ae9597 100644 --- a/tests/testthat/test_fit_interfaces.R +++ b/tests/testthat/test_fit_interfaces.R @@ -60,3 +60,22 @@ test_that('single column df for issue #129', { expect_equal(coef(lm1), coef(lm3)) expect_equal(coef(lm2), coef(lm3)) }) + +# ------------------------------------------------------------------------------ + +test_that('unknown modes', { + mars_spec <- set_engine(mars(), "earth") + expect_error( + fit(mars_spec, am ~ ., data = mtcars), + "Please set the mode in the model specification." + ) + expect_error( + fit_xy(mars_spec, x = mtcars[, -1], y = mtcars[,1]), + regexp = NA + ) + expect_error( + fit_xy(mars_spec, x = lending_club[,1:2], y = lending_club$Class), + regexp = NA + ) +}) + diff --git a/tests/testthat/test_linear_reg_stan.R b/tests/testthat/test_linear_reg_stan.R index d628fa443..012e73539 100644 --- a/tests/testthat/test_linear_reg_stan.R +++ b/tests/testthat/test_linear_reg_stan.R @@ -19,6 +19,7 @@ quiet_ctrl <- fit_control(verbosity = 0L, catch = TRUE) test_that('stan_glm execution', { skip_if_not_installed("rstanarm") + skip_on_cran() expect_error( res <- fit( @@ -56,6 +57,7 @@ test_that('stan_glm execution', { test_that('stan prediction', { skip_if_not_installed("rstanarm") + skip_on_cran() uni_pred <- c(5.01531691055198, 4.6896592504705, 4.74907435900005, 4.82563873798984, 5.08044844256827) @@ -84,6 +86,7 @@ test_that('stan prediction', { test_that('stan intervals', { skip_if_not_installed("rstanarm") + skip_on_cran() res_xy <- fit_xy( linear_reg() %>% @@ -115,15 +118,15 @@ test_that('stan intervals', { pi_upper <- c(5.59783267637042, 5.25976504318669, 5.33296516452929, 5.41050668003565, 5.66355828140989) - expect_equivalent(confidence_parsnip$.pred_lower, ci_lower) - expect_equivalent(confidence_parsnip$.pred_upper, ci_upper) + expect_equivalent(confidence_parsnip$.pred_lower, ci_lower, tolerance = 1e-2) + expect_equivalent(confidence_parsnip$.pred_upper, ci_upper, tolerance = 1e-2) expect_equivalent(prediction_parsnip$.pred_lower, pi_lower, - tol = 0.01) + tolerance = 1e-2) expect_equivalent(prediction_parsnip$.pred_upper, pi_upper, - tol = 0.01) + tolerance = 1e-2) }) diff --git a/tests/testthat/test_logistic_reg_stan.R b/tests/testthat/test_logistic_reg_stan.R index 18940994c..8a0f204e9 100644 --- a/tests/testthat/test_logistic_reg_stan.R +++ b/tests/testthat/test_logistic_reg_stan.R @@ -23,6 +23,7 @@ quiet_ctrl <- fit_control(verbosity = 0, catch = TRUE) test_that('stan_glm execution', { skip_if_not_installed("rstanarm") + skip_on_cran() expect_error( res <- fit( @@ -47,6 +48,7 @@ test_that('stan_glm execution', { test_that('stan_glm prediction', { skip_if_not_installed("rstanarm") + skip_on_cran() xy_fit <- fit_xy( logistic_reg() %>% @@ -80,6 +82,7 @@ test_that('stan_glm prediction', { test_that('stan_glm probability', { skip_if_not_installed("rstanarm") + skip_on_cran() xy_fit <- fit_xy( logistic_reg() %>% @@ -135,6 +138,7 @@ test_that('stan_glm probability', { test_that('stan intervals', { skip_if_not_installed("rstanarm") + skip_on_cran() res_form <- fit( logistic_reg() %>%