@@ -73,3 +73,58 @@ test_that("tailor_requires_fit works", {
73
73
)
74
74
)
75
75
})
76
+
77
+ test_that(" fit.tailor() errors informatively with incompatible outcome" , {
78
+ skip_if_not_installed(" modeldata" )
79
+ library(modeldata )
80
+
81
+ two_class_example $ test_numeric <- two_class_example $ Class1 + 1
82
+ two_class_example $ test_date <- as.POSIXct(two_class_example $ Class1 )
83
+
84
+ # supply a numeric outcome to a binary tailor
85
+ expect_snapshot(
86
+ error = TRUE ,
87
+ fit(
88
+ tailor() %> % adjust_probability_threshold(.1 ),
89
+ two_class_example ,
90
+ outcome = c(test_numeric ),
91
+ estimate = c(predicted ),
92
+ probabilities = c(Class1 , Class2 )
93
+ )
94
+ )
95
+
96
+ # supply a factor outcome to a regression tailor
97
+ expect_snapshot(
98
+ error = TRUE ,
99
+ fit(
100
+ tailor() %> % adjust_numeric_range(lower_limit = .1 ),
101
+ two_class_example ,
102
+ outcome = c(truth ),
103
+ estimate = c(Class1 )
104
+ )
105
+ )
106
+
107
+ # supply a totally wild outcome to a regression tailor
108
+ expect_snapshot(
109
+ error = TRUE ,
110
+ fit(
111
+ tailor() %> % adjust_probability_threshold(.1 ),
112
+ two_class_example ,
113
+ outcome = c(test_date ),
114
+ estimate = c(predicted ),
115
+ probabilities = c(Class1 , Class2 )
116
+ )
117
+ )
118
+
119
+ # supply a totally wild outcome to an unknown tailor
120
+ expect_snapshot(
121
+ error = TRUE ,
122
+ fit(
123
+ tailor() %> % adjust_predictions_custom(hey = " there" ),
124
+ two_class_example ,
125
+ outcome = c(test_date ),
126
+ estimate = c(predicted ),
127
+ probabilities = c(Class1 )
128
+ )
129
+ )
130
+ })
0 commit comments