Skip to content

Commit

Permalink
Merge pull request #56 from ropensci/issue55
Browse files Browse the repository at this point in the history
allow empty numeric data
  • Loading branch information
bcjaeger authored Apr 30, 2024
2 parents 635c41c + eedb190 commit 22c1360
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions R/orsf_R6.R
Original file line number Diff line number Diff line change
Expand Up @@ -2503,6 +2503,15 @@ ObliqueForest <- R6::R6Class(

numeric_data <- select_cols(self$data, private$data_names$x_numeric)

if(is_empty(numeric_data)){

private$data_bounds <- matrix(NA, nrow=5, ncol=1,
dimnames = list(c('10%', '25%', '50%', '75%', '90%'),
"placeholder"))
return()

}

if(self$na_action == 'omit'){
numeric_data <- collapse::fsubset(numeric_data, private$data_rows_complete)
}
Expand Down
17 changes: 17 additions & 0 deletions tests/testthat/test-orsf.R
Original file line number Diff line number Diff line change
Expand Up @@ -988,3 +988,20 @@ test_that(

}
)

test_that(
desc = "data without numerics are allowed",
code = {

fit <- orsf(pbc_orsf, time + status ~ sex + trt, n_tree = n_tree_test)

expect_true(all(is.na(fit$get_bounds())))

expect_equal(length(orsf_vi(fit)), 2L)

skip_on_cran()
# don't require too much compute time from cran
expect_equal(nrow(orsf_pd_oob(fit, pred_spec_auto(sex, trt))), 4L)

}
)

0 comments on commit 22c1360

Please sign in to comment.