Skip to content

Commit b917cac

Browse files
committed
Fixes #523 and global typo fix ("not a a " to "not a ")
1 parent 14b6aea commit b917cac

File tree

10 files changed

+26
-27
lines changed

10 files changed

+26
-27
lines changed

R/misc.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,15 @@ is_class_pred <- function(x) {
6262
inherits(x, "class_pred")
6363
}
6464

65-
as_factor_from_class_pred <- function(x, call) {
65+
as_factor_from_class_pred <- function(x, call = caller_env()) {
6666
if (!is_class_pred(x)) {
6767
return(x)
6868
}
6969

7070
if (!is_installed("probably")) {
71-
cli::cli_abort(
72-
"A {.cls class_pred} input was detected, but the {.pkg probably}
73-
package isn't installed. Install {.pkg probably} to be able to convert
74-
{.cls class_pred} to {.cls factor}.",
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}."),
7574
call = call
7675
)
7776
}

tests/testthat/_snaps/aaa-metrics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
Error in `metric_set()`:
77
! Failed to compute `accuracy()`.
88
Caused by error:
9-
! `estimate` should be a factor, not a a double vector.
9+
! `estimate` should be a factor, not a double vector.
1010

1111
---
1212

tests/testthat/_snaps/check_metric.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
check_class_metric(1, "1", 1)
2929
Condition
3030
Error:
31-
! `truth` should be a factor, not a a number.
31+
! `truth` should be a factor, not a number.
3232

3333
# check_class_metric() validates estimator
3434

tests/testthat/_snaps/error-handling.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
sens(df, truth, estimate)
1414
Condition
1515
Error in `sens()`:
16-
! `truth` should be a factor, not a a number.
16+
! `truth` should be a factor, not a number.
1717

1818
# At least 2 levels in truth
1919

tests/testthat/_snaps/fair-aaa.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@
9292
bad_truth_metric_set(hpc_cv, truth = VF, estimate = pred)
9393
Condition
9494
Error in `bop()`:
95-
! `truth` should be a factor, not a a double vector.
95+
! `truth` should be a factor, not a double vector.
9696

9797
---
9898

9999
Code
100100
bad_truth_metric(hpc_cv, truth = VF, estimate = pred)
101101
Condition
102102
Error in `bop()`:
103-
! `truth` should be a factor, not a a double vector.
103+
! `truth` should be a factor, not a double vector.
104104

105105
# outputted function errors informatively with redundant grouping
106106

tests/testthat/_snaps/orderedprob-ranked_prob_score.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ranked_prob_score_vec(two_class_example$truth, estimate)
1313
Condition
1414
Error in `ranked_prob_score_vec()`:
15-
! `truth` should be a ordered factor, not a a <factor> object.
15+
! `truth` should be a ordered factor, not a <factor> object.
1616

1717
---
1818

tests/testthat/_snaps/prob-gain_curve.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
gain_curve(df, truth, estimate)
55
Condition
66
Error in `gain_curve()`:
7-
! `truth` should be a factor, not a a number.
7+
! `truth` should be a factor, not a number.
88

99
# na_rm = FALSE errors if missing values are present
1010

tests/testthat/_snaps/prob-lift_curve.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
lift_curve(df, truth, estimate)
55
Condition
66
Error in `lift_curve()`:
7-
! `truth` should be a factor, not a a number.
7+
! `truth` should be a factor, not a number.
88

99
# errors with class_pred input
1010

tests/testthat/_snaps/template.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173
data = lung_surv, truth = .pred_time, .pred)
174174
Condition
175175
Error:
176-
! `truth` should be a Surv object, not a a double vector.
176+
! `truth` should be a Surv object, not a double vector.
177177

178178
---
179179

@@ -182,7 +182,7 @@
182182
data = lung_surv, truth = surv_obj, surv_obj)
183183
Condition
184184
Error:
185-
! `estimate` should be a list, not a a <Surv> object.
185+
! `estimate` should be a list, not a <Surv> object.
186186

187187
---
188188

@@ -250,7 +250,7 @@
250250
data = lung_surv, truth = .pred_time, .pred)
251251
Condition
252252
Error:
253-
! `truth` should be a Surv object, not a a double vector.
253+
! `truth` should be a Surv object, not a double vector.
254254

255255
---
256256

@@ -259,7 +259,7 @@
259259
data = lung_surv, truth = surv_obj, surv_obj)
260260
Condition
261261
Error:
262-
! `estimate` should be a list, not a a <Surv> object.
262+
! `estimate` should be a list, not a <Surv> object.
263263

264264
---
265265

tests/testthat/_snaps/validation.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
validate_factor_truth_factor_estimate("1", 1)
5454
Condition
5555
Error:
56-
! `truth` should be a factor, not a a string.
56+
! `truth` should be a factor, not a string.
5757

5858
---
5959

@@ -62,7 +62,7 @@
6262
levels = c("a", "b")))
6363
Condition
6464
Error:
65-
! `truth` should be a factor, not a a character vector.
65+
! `truth` should be a factor, not a character vector.
6666

6767
---
6868

@@ -71,7 +71,7 @@
7171
"b")), c("a", "b", "a"))
7272
Condition
7373
Error:
74-
! `estimate` should be a factor, not a a character vector.
74+
! `estimate` should be a factor, not a character vector.
7575

7676
---
7777

@@ -108,7 +108,7 @@
108108
validate_factor_truth_matrix_estimate(c("a", "b", "a"), 1:3, estimator = "binary")
109109
Condition
110110
Error:
111-
! `truth` should be a factor, not a a character vector.
111+
! `truth` should be a factor, not a character vector.
112112

113113
---
114114

@@ -144,7 +144,7 @@
144144
estimator = "non binary")
145145
Condition
146146
Error:
147-
! `truth` should be a factor, not a a character vector.
147+
! `truth` should be a factor, not a character vector.
148148

149149
---
150150

@@ -179,7 +179,7 @@
179179
validate_ordered_truth_matrix_estimate(c("a", "b", "a"), 1:3, estimator = "binary")
180180
Condition
181181
Error:
182-
! `truth` should be a ordered factor, not a a character vector.
182+
! `truth` should be a ordered factor, not a character vector.
183183

184184
---
185185

@@ -215,7 +215,7 @@
215215
estimator = "non binary")
216216
Condition
217217
Error:
218-
! `truth` should be a ordered factor, not a a character vector.
218+
! `truth` should be a ordered factor, not a character vector.
219219

220220
---
221221

@@ -276,7 +276,7 @@
276276
validate_surv_truth_list_estimate("1", 1)
277277
Condition
278278
Error:
279-
! `truth` should be a Surv object, not a a string.
279+
! `truth` should be a Surv object, not a string.
280280

281281
---
282282

@@ -309,7 +309,7 @@
309309
.pred_time))
310310
Condition
311311
Error:
312-
! `estimate` should be a list, not a a character vector.
312+
! `estimate` should be a list, not a character vector.
313313

314314
---
315315

@@ -318,7 +318,7 @@
318318
.pred_time)
319319
Condition
320320
Error:
321-
! `estimate` should be a list, not a a double vector.
321+
! `estimate` should be a list, not a double vector.
322322

323323
---
324324

0 commit comments

Comments
 (0)