Skip to content

Commit

Permalink
assert importance is specified
Browse files Browse the repository at this point in the history
  • Loading branch information
bcjaeger committed Nov 22, 2024
1 parent 324d614 commit 7538f50
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions R/orsf_vs.R
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ orsf_vs <- function(object,
n_predictor_drop = 1,
verbose_progress = NULL){

if(object$importance_type == 'none'){
stop("object must be specified with importance",
"of 'anova', 'negate', or 'permute'",
call. = FALSE)
}

check_arg_is(arg_value = object,
arg_name = 'object',
expected_class = 'ObliqueForest')
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-orsf_vs.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,17 @@ test_that(
}
)

test_that(
desc = "importance specification is required",
code = {

fit_cars <- orsf(mpg ~ ., data = mtcars,
n_tree = n_tree_test,
importance = 'none')

expect_error(orsf_vs(fit_cars), regexp = 'must be specified')

}
)


0 comments on commit 7538f50

Please sign in to comment.