Skip to content

Commit

Permalink
smoothing the new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Oct 5, 2023
1 parent 041805b commit a7b0762
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
18 changes: 6 additions & 12 deletions man/orsf.Rd

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

6 changes: 4 additions & 2 deletions tests/testthat/test-leaf_kaplan.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
#' @srrstats {G5.5} *Correctness tests are run with a fixed random seed*
set.seed(329)

flc <- flc[flc$status==1, ]

weights <- sample(1:5, nrow(flc), replace = TRUE)

# fit a normal tree with no bootstrap weights
fit <- orsf(flc,
futime + death ~ .,
time + status ~ .,
n_tree = 1,
weights = weights,
tree_seeds = 1,
Expand All @@ -27,7 +29,7 @@ fit <- orsf(flc,
aorsf_surv <- fit$forest$leaf_pred_prob[[1]][[1]]
aorsf_time <- fit$forest$leaf_pred_indx[[1]][[1]]

kap <- survfit(Surv(futime, death) ~ 1, data = flc, weights = weights)
kap <- survfit(Surv(time, status) ~ 1, data = flc, weights = weights)

test_that(
desc = 'aorsf kaplan has same time values as survfit',
Expand Down
6 changes: 3 additions & 3 deletions tests/testthat/test-orsf_formula.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test_that(
# keeps unique names
expect_equal(x_vars, get_names_x(fit_long))
# is the same forest as standard
expect_equal_leaf_summary(fit_long, fit_standard)
expect_equal_leaf_summary(fit_long, fit_standard_pbc)

}
)
Expand All @@ -95,7 +95,7 @@ test_that(
)

# different formula but same as standard forest
expect_equal_leaf_summary(fit_surv, fit_standard)
expect_equal_leaf_summary(fit_surv, fit_standard_pbc)
}
)

Expand All @@ -111,7 +111,7 @@ test_that(
n_tree = 10,
tree_seeds = seeds_standard)

expect_equal_leaf_summary(fit_status_modified, fit_standard)
expect_equal_leaf_summary(fit_status_modified, fit_standard_pbc)

expect_error(
orsf(pbc_orsf, Surv(status, time) ~ . - id),
Expand Down
2 changes: 2 additions & 0 deletions tests/testthat/test-orsf_vi.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ test_that(
desc = 'informative errors for custom functions',
code = {

fit_no_vi <- orsf(pbc_vi, formula, importance = 'none', n_tree = 1)

expect_error(
orsf_vi_anova(object = 'nope'),
regexp = 'inherit'
Expand Down

0 comments on commit a7b0762

Please sign in to comment.