Skip to content

Commit 67441af

Browse files
committed
don't use is_installed() AND check_installed()
1 parent 4ee470b commit 67441af

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

R/misc.R

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ as_factor_from_class_pred <- function(x, call = caller_env()) {
6767
return(x)
6868
}
6969

70-
if (!is_installed("probably")) {
71-
check_installed(
72-
pkg = "probably",
73-
reason = cli::format_inline("\nA {.cls class_pred} input was detected and {.pkg probably} is required to convert {.cls class_pred} to {.cls factor}."),
74-
call = call
75-
)
76-
}
70+
check_installed(
71+
pkg = "probably",
72+
reason = cli::format_inline(
73+
"\nA {.cls class_pred} input was detected and {.pkg probably} is required to convert {.cls class_pred} to {.cls factor}."
74+
),
75+
call = call
76+
)
77+
7778
probably::as.factor(x)
7879
}
7980

tests/testthat/test-misc.R

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,16 +368,4 @@ test_that("work with class_pred input", {
368368

369369
fct_estimate <- two_class_example$predicted
370370
fct_estimate[2] <- NA
371-
372-
local_mocked_bindings(
373-
.package = "rlang",
374-
detect_installed = function(pkg, ...) {
375-
FALSE
376-
}
377-
)
378-
379-
expect_snapshot(
380-
error = TRUE,
381-
accuracy_vec(fct_truth, cp_estimate)
382-
)
383371
})

0 commit comments

Comments
 (0)