@@ -111,7 +111,7 @@ fit.model_spec <-
111
111
...
112
112
) {
113
113
if (object $ mode == " unknown" ) {
114
- rlang :: abort (" Please set the mode in the model specification." )
114
+ cli :: cli_abort (" Please set the mode in the model specification." )
115
115
}
116
116
control <- condense_control(control , control_parsnip())
117
117
check_case_weights(case_weights , object )
@@ -145,12 +145,12 @@ fit.model_spec <-
145
145
eng_vals <- possible_engines(object )
146
146
object $ engine <- eng_vals [1 ]
147
147
if (control $ verbosity > 0 ) {
148
- rlang :: warn( glue :: glue( " Engine set to `{ object$engine}`. " ) )
148
+ cli :: cli_warn( " Engine set to {.val { object$engine}}. " )
149
149
}
150
150
}
151
151
152
152
if (all(c(" x" , " y" ) %in% names(dots ))) {
153
- rlang :: abort (" `fit.model_spec()` is for the formula methods. Use `fit_xy()` instead." )
153
+ cli :: cli_abort (" `fit.model_spec()` is for the formula methods. Use `fit_xy()` instead." )
154
154
}
155
155
cl <- match.call(expand.dots = TRUE )
156
156
# Create an environment with the evaluated argument objects. This will be
@@ -173,12 +173,11 @@ fit.model_spec <-
173
173
check_interface(eval_env $ formula , eval_env $ data , cl , object )
174
174
175
175
if (object $ engine == " spark" && ! inherits(eval_env $ data , " tbl_spark" ))
176
- rlang :: abort(
177
- glue :: glue(
178
- " spark objects can only be used with the formula interface to `fit()` " ,
179
- " with a spark data object."
176
+ cli :: cli_abort(
177
+ " spark objects can only be used with the formula interface to {.fn fit}
178
+ with a spark data object."
180
179
)
181
- )
180
+
182
181
183
182
# populate `method` with the details for this model type
184
183
object <- add_methods(object , engine = object $ engine )
@@ -221,7 +220,7 @@ fit.model_spec <-
221
220
...
222
221
),
223
222
224
- rlang :: abort( glue :: glue( " { interfaces} is unknown." ) )
223
+ cli :: cli_abort( " {.val { interfaces}} is unknown." )
225
224
)
226
225
res $ censor_probs <- reverse_km(object , eval_env )
227
226
model_classes <- class(res $ fit )
@@ -243,17 +242,17 @@ fit_xy.model_spec <-
243
242
...
244
243
) {
245
244
if (object $ mode == " unknown" ) {
246
- rlang :: abort (" Please set the mode in the model specification." )
245
+ cli :: cli_abort (" Please set the mode in the model specification." )
247
246
}
248
247
249
248
if (inherits(object , " surv_reg" )) {
250
- rlang :: abort (" Survival models must use the formula interface." )
249
+ cli :: cli_abort (" Survival models must use the formula interface." )
251
250
}
252
251
253
252
control <- condense_control(control , control_parsnip())
254
253
255
254
if (is.null(colnames(x ))) {
256
- rlang :: abort( " 'x' should have column names." )
255
+ cli :: cli_abort( " {.arg {x}} should have column names." )
257
256
}
258
257
check_case_weights(case_weights , object )
259
258
@@ -262,7 +261,7 @@ fit_xy.model_spec <-
262
261
eng_vals <- possible_engines(object )
263
262
object $ engine <- eng_vals [1 ]
264
263
if (control $ verbosity > 0 ) {
265
- rlang :: warn( glue :: glue( " Engine set to `{ object$engine}`. " ) )
264
+ cli :: cli_warn( " Engine set to {.val { object$engine}}. " )
266
265
}
267
266
}
268
267
y_var <- colnames(y )
@@ -286,11 +285,8 @@ fit_xy.model_spec <-
286
285
fit_interface <- check_xy_interface(eval_env $ x , eval_env $ y , cl , object )
287
286
288
287
if (object $ engine == " spark" )
289
- rlang :: abort(
290
- glue :: glue(
291
- " spark objects can only be used with the formula interface to `fit()` " ,
292
- " with a spark data object."
293
- )
288
+ cli :: cli_abort(
289
+ " spark objects can only be used with the formula interface to {.fn fit} with a spark data object."
294
290
)
295
291
296
292
# populate `method` with the details for this model type
@@ -335,7 +331,7 @@ fit_xy.model_spec <-
335
331
control = control ,
336
332
...
337
333
),
338
- rlang :: abort( glue :: glue( " { interfaces} is unknown." ) )
334
+ cli :: cli_abort( " {.val { interfaces}} is unknown." )
339
335
)
340
336
res $ censor_probs <- reverse_km(object , eval_env )
341
337
model_classes <- class(res $ fit )
@@ -366,19 +362,16 @@ eval_mod <- function(e, capture = FALSE, catch = FALSE, envir = NULL, ...) {
366
362
367
363
inher <- function (x , cls , cl ) {
368
364
if (! is.null(x ) && ! inherits(x , cls )) {
365
+
369
366
call <- match.call()
370
367
obj <- deparse(call [[" x" ]])
368
+
371
369
if (length(cls ) > 1 )
372
- rlang :: abort(
373
- glue :: glue(
374
- " `{obj}` should be one of the following classes: " ,
375
- glue :: glue_collapse(glue :: glue(" '{cls}'" ), sep = " , " )
376
- )
377
- )
370
+ cli :: cli_abort(
371
+ " {.arg {obj}} should be one of the following classes: {.cls {cls}}." )
372
+
378
373
else
379
- rlang :: abort(
380
- glue :: glue(" `{obj}` should be a {cls} object" )
381
- )
374
+ cli :: cli_abort(" {.arg {obj}} should be a {.cls {cls}} object" )
382
375
}
383
376
invisible (x )
384
377
}
@@ -394,15 +387,15 @@ check_interface <- function(formula, data, cl, model) {
394
387
395
388
if (form_interface )
396
389
return (" formula" )
397
- rlang :: abort (" Error when checking the interface." )
390
+ cli :: cli_abort (" Error when checking the interface." )
398
391
}
399
392
400
393
check_xy_interface <- function (x , y , cl , model ) {
401
394
402
395
sparse_ok <- allow_sparse(model )
403
396
sparse_x <- inherits(x , " dgCMatrix" )
404
397
if (! sparse_ok & sparse_x ) {
405
- rlang :: abort (" Sparse matrices not supported by this model/engine combination." )
398
+ cli :: cli_abort (" Sparse matrices not supported by this model/engine combination." )
406
399
}
407
400
408
401
if (sparse_ok ) {
@@ -416,11 +409,8 @@ check_xy_interface <- function(x, y, cl, model) {
416
409
417
410
# rule out spark data sets that don't use the formula interface
418
411
if (inherits(x , " tbl_spark" ) | inherits(y , " tbl_spark" ))
419
- rlang :: abort(
420
- glue :: glue(
421
- " spark objects can only be used with the formula interface via `fit()` " ,
422
- " with a spark data object."
423
- )
412
+ cli :: cli_abort(
413
+ " spark objects can only be used with the formula interface via {.fn fit} with a spark data object."
424
414
)
425
415
426
416
@@ -441,7 +431,7 @@ check_xy_interface <- function(x, y, cl, model) {
441
431
442
432
check_outcome(y , model )
443
433
444
- rlang :: abort (" Error when checking the interface" )
434
+ cli :: cli_abort (" Error when checking the interface" )
445
435
}
446
436
447
437
allow_sparse <- function (x ) {
0 commit comments