Skip to content

Commit 6dc72df

Browse files
committed
a couple more test fixes
1 parent 35ec46e commit 6dc72df

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

tests/testthat/test_convert_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ test_that("1 col matrix x, 1 col matrix y", {
449449

450450
test_that("matrix x, factor y", {
451451
observed <- parsnip:::convert_xy_to_form_fit(as.matrix(hpc[, -5]), hpc$class)
452-
expected <- hpc
452+
expected <- as.data.frame(hpc)
453453
names(expected)[5] <- "..y"
454454
expect_equal(expected, observed$data)
455455
expect_equal(formula("..y ~ ."), observed$formula)

tests/testthat/test_nullmodel.R

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ library(rlang)
44
library(tibble)
55

66
context("test-nullmodel")
7-
source("helpers.R")
7+
source(test_path("helpers.R"))
88
source(test_path("helper-objects.R"))
9-
hpc <- hpc_data[1:150, c(2:5, 8)]
9+
hpc <- hpc_data[1:150, c(2:5, 8)] %>% as.data.frame()
1010

1111
test_that('primary arguments', {
1212
basic <- null_model(mode = "regression")
@@ -44,7 +44,7 @@ test_that('bad input', {
4444

4545
# ------------------------------------------------------------------------------
4646

47-
num_pred <- names(phc)[1:3]
47+
num_pred <- names(hpc)[1:3]
4848
hpc_bad_form <- as.formula(class ~ term)
4949
hpc_basic <- null_model(mode = "regression") %>% set_engine("parsnip")
5050

@@ -92,8 +92,8 @@ test_that('nullmodel execution', {
9292

9393
test_that('nullmodel prediction', {
9494

95-
uni_pred <- tibble(.pred = rep(3.758, 5))
96-
inl_pred <- rep(3.758, 5)
95+
uni_pred <- tibble(.pred = rep(30.1, 5))
96+
inl_pred <- rep(30.1, 5)
9797
mw_pred <- tibble(gear = rep(3.6875, 5),
9898
carb = rep(2.8125, 5))
9999

@@ -103,14 +103,18 @@ test_that('nullmodel prediction', {
103103
y = hpc$num_pending
104104
)
105105

106-
expect_equal(uni_pred, predict(res_xy, new_data = hpc[1:5, num_pred]))
106+
expect_equal(uni_pred,
107+
predict(res_xy, new_data = hpc[1:5, num_pred]),
108+
tolerance = .01)
107109

108110
res_form <- fit(
109111
hpc_basic,
110112
num_pending ~ log(compounds) + class,
111-
data = hpc_basic
113+
data = hpc
112114
)
113-
expect_equal(inl_pred, predict(res_form, hpc[1:5, ])$.pred)
115+
expect_equal(inl_pred,
116+
predict(res_form, hpc[1:5, ])$.pred,
117+
tolerance = .01)
114118

115119
# Multivariate y
116120
res <- fit(

0 commit comments

Comments
 (0)