Skip to content

Commit

Permalink
mtcars was causing issues in cmd check
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Nov 18, 2023
1 parent d238920 commit f931c0c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 44 deletions.
33 changes: 4 additions & 29 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,20 +68,6 @@ for(i in vars){
# make sorted x and y matrices for testing internal cpp functions
penguins_mats <- prep_test_matrices(penguins, outcomes = c("species"))

# mtcars ----

mtcars_scale <- mtcars_noise <- mtcars

vars <- c("drat", "wt", "qsec", "disp")

for(i in vars){
mtcars_noise[[i]] <- add_noise(mtcars_noise[[i]])
mtcars_scale[[i]] <- change_scale(mtcars_scale[[i]])
}

# make sorted x and y matrices for testing internal cpp functions
mtcars_mats <- prep_test_matrices(mtcars, outcomes = c("mpg"))

# data lists ----

data_list_pbc <- list(pbc_standard = pbc,
Expand All @@ -93,13 +79,6 @@ data_list_penguins <- list(penguins_standard = penguins,
penguins_scaled = penguins_scale,
penguins_noised = penguins_noise)

data_list_mtcars <- list(mtcars_standard = mtcars,
mtcars_scaled = mtcars_scale,
mtcars_noised = mtcars_noise)





# matrix lists ----

Expand Down Expand Up @@ -137,7 +116,7 @@ controls_clsf <- list(
custom = orsf_control_classification(method = f_pca)
)

fit_standard_penguins <- lapply(
fit_standard_penguin_species <- lapply(
controls_clsf,
function(cntrl){
orsf(penguins,
Expand All @@ -154,11 +133,11 @@ controls_regr <- list(
custom = orsf_control_regression(method = f_pca)
)

fit_standard_mtcars <- lapply(
fit_standard_penguin_bills <- lapply(
controls_regr,
function(cntrl){
orsf(mtcars,
formula = mpg ~ .,
orsf(penguins,
formula = bill_length_mm ~ .,
n_tree = n_tree_test,
control = cntrl,
tree_seed = seeds_standard)
Expand Down Expand Up @@ -188,7 +167,3 @@ penguins_train_rows <- sample(nrow(penguins_orsf), size = 180)
penguins_train <- penguins[penguins_train_rows, ]
penguins_test <- penguins[-penguins_train_rows, ]

mtcars_train_rows <- sample(nrow(mtcars), size = 16)
mtcars_train <- mtcars[mtcars_train_rows, ]
mtcars_test <- mtcars[-mtcars_train_rows, ]

4 changes: 2 additions & 2 deletions tests/testthat/test-impute_meanmode.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ test_that(
}
)

# Note: eval_oobag is not the same,
# Note: eval_oobag is not the same on ubuntu,
# maybe because fit_imputed x is scaled using imputed values?

test_that(
desc = 'fit with impute is identical to fit on imputed',
code = {
skip()
skip_on_os(os = 'linux')
expect_equal_leaf_summary(fit_miss, fit_imputed)
expect_equal(fit_miss$n_obs, fit_imputed$n_obs)
}
Expand Down
26 changes: 13 additions & 13 deletions tests/testthat/test-orsf.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,15 @@ test_that(
control = controls_clsf$fast,
tree_seed = seeds_standard)

expect_equal_leaf_summary(fit_dt, fit_standard_penguins$fast)
expect_equal_leaf_summary(fit_dt, fit_standard_penguin_species$fast)

fit_dt <- orsf(as.data.table(mtcars),
formula = mpg ~ .,
fit_dt <- orsf(as.data.table(penguins),
formula = bill_length_mm ~ .,
n_tree = n_tree_test,
control = controls_regr$fast,
tree_seed = seeds_standard)

expect_equal_leaf_summary(fit_dt, fit_standard_mtcars$fast)
expect_equal_leaf_summary(fit_dt, fit_standard_penguin_bills$fast)

}
)
Expand Down Expand Up @@ -358,27 +358,27 @@ test_that(
})

expect_equal_oobag_eval(fits_clsf$penguins_scaled,
fit_standard_penguins$fast,
fit_standard_penguin_species$fast,
tolerance = .01)

expect_equal_oobag_eval(fits_clsf$penguins_noised,
fit_standard_penguins$fast,
fit_standard_penguin_species$fast,
tolerance = .01)

fits_regr <- lapply(data_list_mtcars[-1], function(data){
fits_regr <- lapply(data_list_penguins[-1], function(data){
orsf(data,
formula = mpg ~ .,
formula = bill_length_mm ~ .,
n_thread = 2,
n_tree = n_tree_test,
tree_seeds = seeds_standard)
})

expect_equal_oobag_eval(fits_regr$mtcars_scaled,
fit_standard_mtcars$fast,
expect_equal_oobag_eval(fits_regr$penguins_scaled,
fit_standard_penguin_bills$fast,
tolerance = .01)

expect_equal_oobag_eval(fits_regr$mtcars_noised,
fit_standard_mtcars$fast,
expect_equal_oobag_eval(fits_regr$penguins_scaled,
fit_standard_penguin_bills$fast,
tolerance = .01)

}
Expand Down Expand Up @@ -445,7 +445,7 @@ test_that(
# oobag_fun = oobag_cstat_clsf,
# tree_seeds = seeds_standard)
#
# expect_equal_oobag_eval(fit, fit_standard_penguins$fast)
# expect_equal_oobag_eval(fit, fit_standard_penguin_species$fast)


}
Expand Down

0 comments on commit f931c0c

Please sign in to comment.