@@ -63,9 +63,10 @@ test_that("resampling survival models with static metric", {
63
63
# test structure of results --------------------------------------------------
64
64
65
65
expect_false(" .eval_time" %in% names(rs_static_res $ .metrics [[1 ]]))
66
- expect_equal(
67
- names(rs_static_res $ .predictions [[1 ]]),
68
- c(" .pred_time" , " .row" , " event_time" , " .config" )
66
+ expect_named(
67
+ rs_static_res $ .predictions [[1 ]],
68
+ c(" .pred_time" , " .row" , " event_time" , " .config" ),
69
+ ignore.order = TRUE
69
70
)
70
71
71
72
# test metric collection -----------------------------------------------------
@@ -82,7 +83,7 @@ test_that("resampling survival models with static metric", {
82
83
)
83
84
84
85
expect_true(nrow(metric_sum ) == 1 )
85
- expect_equal (metric_sum [ 0 ,] , exp_metric_sum )
86
+ expect_ptype (metric_sum , exp_metric_sum )
86
87
expect_true(all(metric_sum $ .metric == " concordance_survival" ))
87
88
88
89
metric_all <- collect_metrics(rs_static_res , summarize = FALSE )
@@ -96,7 +97,8 @@ test_that("resampling survival models with static metric", {
96
97
)
97
98
98
99
expect_true(nrow(metric_all ) == 10 )
99
- expect_equal(metric_all [0 ,], exp_metric_all )
100
+ expect_ptype(metric_all , exp_metric_all )
101
+
100
102
expect_true(all(metric_all $ .metric == " concordance_survival" ))
101
103
102
104
# test prediction collection -------------------------------------------------
@@ -110,11 +112,11 @@ test_that("resampling survival models with static metric", {
110
112
)
111
113
112
114
unsum_pred <- collect_predictions(rs_static_res )
113
- expect_equal (unsum_pred [ 0 ,] , static_ptype )
115
+ expect_ptype (unsum_pred , static_ptype )
114
116
expect_equal(nrow(unsum_pred ), nrow(sim_tr ))
115
117
116
118
sum_pred <- collect_predictions(rs_static_res , summarize = TRUE )
117
- expect_equal (sum_pred [ 0 ,] , static_ptype [, names(static_ptype ) != " id" ])
119
+ expect_ptype (sum_pred , static_ptype [, names(static_ptype ) != " id" ])
118
120
expect_equal(nrow(sum_pred ), nrow(sim_tr ))
119
121
120
122
})
@@ -161,14 +163,17 @@ test_that("resampling survival models with integrated metric", {
161
163
# test structure of results --------------------------------------------------
162
164
163
165
expect_false(" .eval_time" %in% names(rs_integrated_res $ .metrics [[1 ]]))
164
- expect_equal(
165
- names(rs_integrated_res $ .predictions [[1 ]]),
166
- c(" .pred" , " .row" , " event_time" , " .config" )
166
+ expect_named(
167
+ rs_integrated_res $ .predictions [[1 ]],
168
+ c(" .pred" , " .row" , " event_time" , " .config" ),
169
+ ignore.order = TRUE
167
170
)
171
+
168
172
expect_true(is.list(rs_integrated_res $ .predictions [[1 ]]$ .pred ))
169
- expect_equal(
170
- names(rs_integrated_res $ .predictions [[1 ]]$ .pred [[1 ]]),
171
- c(" .eval_time" , " .pred_survival" , " .weight_censored" )
173
+ expect_named(
174
+ rs_integrated_res $ .predictions [[1 ]]$ .pred [[1 ]],
175
+ c(" .eval_time" , " .pred_survival" , " .weight_censored" ),
176
+ ignore.order = TRUE
172
177
)
173
178
expect_equal(
174
179
rs_integrated_res $ .predictions [[1 ]]$ .pred [[1 ]]$ .eval_time ,
@@ -189,7 +194,7 @@ test_that("resampling survival models with integrated metric", {
189
194
)
190
195
191
196
expect_true(nrow(metric_sum ) == 1 )
192
- expect_equal (metric_sum [ 0 ,] , exp_metric_sum )
197
+ expect_ptype (metric_sum , exp_metric_sum )
193
198
expect_true(all(metric_sum $ .metric == " brier_survival_integrated" ))
194
199
195
200
metric_all <- collect_metrics(rs_integrated_res , summarize = FALSE )
@@ -203,7 +208,7 @@ test_that("resampling survival models with integrated metric", {
203
208
)
204
209
205
210
expect_true(nrow(metric_all ) == 10 )
206
- expect_equal (metric_all [ 0 ,] , exp_metric_all )
211
+ expect_ptype (metric_all , exp_metric_all )
207
212
expect_true(all(metric_all $ .metric == " brier_survival_integrated" ))
208
213
209
214
# test prediction collection -------------------------------------------------
@@ -224,17 +229,17 @@ test_that("resampling survival models with integrated metric", {
224
229
)
225
230
226
231
unsum_pred <- collect_predictions(rs_integrated_res )
227
- expect_equal (unsum_pred [ 0 ,] , integrated_ptype )
232
+ expect_ptype (unsum_pred , integrated_ptype )
228
233
expect_equal(nrow(unsum_pred ), nrow(sim_tr ))
229
234
230
- expect_equal (unsum_pred $ .pred [[1 ]][ 0 , ], integrated_list_ptype )
235
+ expect_ptype (unsum_pred $ .pred [[1 ]], integrated_list_ptype )
231
236
expect_equal(nrow(unsum_pred $ .pred [[1 ]]), length(time_points ))
232
237
233
238
sum_pred <- collect_predictions(rs_integrated_res , summarize = TRUE )
234
- expect_equal (sum_pred [ 0 ,] , integrated_ptype [, names(integrated_ptype ) != " id" ])
239
+ expect_ptype (sum_pred , integrated_ptype [, names(integrated_ptype ) != " id" ])
235
240
expect_equal(nrow(sum_pred ), nrow(sim_tr ))
236
241
237
- expect_equal (sum_pred $ .pred [[1 ]][ 0 , ], integrated_list_ptype )
242
+ expect_ptype (sum_pred $ .pred [[1 ]], integrated_list_ptype )
238
243
expect_equal(nrow(sum_pred $ .pred [[1 ]]), length(time_points ))
239
244
240
245
})
@@ -281,14 +286,18 @@ test_that("resampling survival models with dynamic metric", {
281
286
# test structure of results --------------------------------------------------
282
287
283
288
expect_true(" .eval_time" %in% names(rs_dynamic_res $ .metrics [[1 ]]))
284
- expect_equal(
285
- names(rs_dynamic_res $ .predictions [[1 ]]),
286
- c(" .pred" , " .row" , " event_time" , " .config" )
289
+
290
+ expect_named(
291
+ rs_dynamic_res $ .predictions [[1 ]],
292
+ c(" .pred" , " .row" , " event_time" , " .config" ),
293
+ ignore.order = TRUE
287
294
)
288
295
expect_true(is.list(rs_dynamic_res $ .predictions [[1 ]]$ .pred ))
289
- expect_equal(
290
- names(rs_dynamic_res $ .predictions [[1 ]]$ .pred [[1 ]]),
291
- c(" .eval_time" , " .pred_survival" , " .weight_censored" )
296
+
297
+ expect_named(
298
+ rs_dynamic_res $ .predictions [[1 ]]$ .pred [[1 ]],
299
+ c(" .eval_time" , " .pred_survival" , " .weight_censored" ),
300
+ ignore.order = TRUE
292
301
)
293
302
expect_equal(
294
303
rs_dynamic_res $ .predictions [[1 ]]$ .pred [[1 ]]$ .eval_time ,
@@ -310,7 +319,7 @@ test_that("resampling survival models with dynamic metric", {
310
319
)
311
320
312
321
expect_true(nrow(metric_sum ) == length(time_points ))
313
- expect_equal (metric_sum [ 0 ,] , exp_metric_sum )
322
+ expect_ptype (metric_sum , exp_metric_sum )
314
323
expect_true(all(metric_sum $ .metric == " brier_survival" ))
315
324
316
325
metric_all <- collect_metrics(rs_dynamic_res , summarize = FALSE )
@@ -325,7 +334,7 @@ test_that("resampling survival models with dynamic metric", {
325
334
)
326
335
327
336
expect_true(nrow(metric_all ) == length(time_points ) * nrow(sim_rs ))
328
- expect_equal (metric_all [ 0 ,] , exp_metric_all )
337
+ expect_ptype (metric_all , exp_metric_all )
329
338
expect_true(all(metric_all $ .metric == " brier_survival" ))
330
339
331
340
# test prediction collection -------------------------------------------------
@@ -346,17 +355,17 @@ test_that("resampling survival models with dynamic metric", {
346
355
)
347
356
348
357
unsum_pred <- collect_predictions(rs_dynamic_res )
349
- expect_equal (unsum_pred [ 0 ,] , dynamic_ptype )
358
+ expect_ptype (unsum_pred , dynamic_ptype )
350
359
expect_equal(nrow(unsum_pred ), nrow(sim_tr ))
351
360
352
- expect_equal (unsum_pred $ .pred [[1 ]][ 0 , ], dynamic_list_ptype )
361
+ expect_ptype (unsum_pred $ .pred [[1 ]], dynamic_list_ptype )
353
362
expect_equal(nrow(unsum_pred $ .pred [[1 ]]), length(time_points ))
354
363
355
364
sum_pred <- collect_predictions(rs_dynamic_res , summarize = TRUE )
356
- expect_equal (sum_pred [ 0 ,] , dynamic_ptype [, names(dynamic_ptype ) != " id" ])
365
+ expect_ptype (sum_pred , dynamic_ptype [, names(dynamic_ptype ) != " id" ])
357
366
expect_equal(nrow(sum_pred ), nrow(sim_tr ))
358
367
359
- expect_equal (sum_pred $ .pred [[1 ]][ 0 , ], dynamic_list_ptype )
368
+ expect_ptype (sum_pred $ .pred [[1 ]], dynamic_list_ptype )
360
369
expect_equal(nrow(sum_pred $ .pred [[1 ]]), length(time_points ))
361
370
362
371
})
@@ -404,14 +413,16 @@ test_that("resampling survival models mixture of metric types", {
404
413
# test structure of results --------------------------------------------------
405
414
406
415
expect_true(" .eval_time" %in% names(rs_mixed_res $ .metrics [[1 ]]))
407
- expect_equal(
408
- names(rs_mixed_res $ .predictions [[1 ]]),
409
- c(" .pred" , " .row" , " .pred_time" , " event_time" , " .config" )
416
+ expect_named(
417
+ rs_mixed_res $ .predictions [[1 ]],
418
+ c(" .pred" , " .row" , " .pred_time" , " event_time" , " .config" ),
419
+ ignore.order = TRUE
410
420
)
411
421
expect_true(is.list(rs_mixed_res $ .predictions [[1 ]]$ .pred ))
412
- expect_equal(
413
- names(rs_mixed_res $ .predictions [[1 ]]$ .pred [[1 ]]),
414
- c(" .eval_time" , " .pred_survival" , " .weight_censored" )
422
+ expect_named(
423
+ rs_mixed_res $ .predictions [[1 ]]$ .pred [[1 ]],
424
+ c(" .eval_time" , " .pred_survival" , " .weight_censored" ),
425
+ ignore.order = TRUE
415
426
)
416
427
expect_equal(
417
428
rs_mixed_res $ .predictions [[1 ]]$ .pred [[1 ]]$ .eval_time ,
@@ -433,7 +444,7 @@ test_that("resampling survival models mixture of metric types", {
433
444
)
434
445
435
446
expect_true(nrow(metric_sum ) == length(time_points ) + 2 )
436
- expect_equal (metric_sum [ 0 ,] , exp_metric_sum )
447
+ expect_ptype (metric_sum , exp_metric_sum )
437
448
expect_true(sum(is.na(metric_sum $ .eval_time )) == 2 )
438
449
expect_equal(as.vector(table(metric_sum $ .metric )), c(length(time_points ), 1L , 1L ))
439
450
@@ -449,7 +460,7 @@ test_that("resampling survival models mixture of metric types", {
449
460
)
450
461
451
462
expect_true(nrow(metric_all ) == (length(time_points ) + 2 ) * nrow(sim_rs ))
452
- expect_equal (metric_all [ 0 ,] , exp_metric_all )
463
+ expect_ptype (metric_all , exp_metric_all )
453
464
expect_true(sum(is.na(metric_all $ .eval_time )) == 2 * nrow(sim_rs ))
454
465
expect_equal(as.vector(table(metric_all $ .metric )), c(length(time_points ), 1L , 1L ) * nrow(sim_rs ))
455
466
@@ -472,17 +483,17 @@ test_that("resampling survival models mixture of metric types", {
472
483
)
473
484
474
485
unsum_pred <- collect_predictions(rs_mixed_res )
475
- expect_equal (unsum_pred [ 0 ,] , mixed_ptype )
486
+ expect_ptype (unsum_pred , mixed_ptype )
476
487
expect_equal(nrow(unsum_pred ), nrow(sim_tr ))
477
488
478
- expect_equal (unsum_pred $ .pred [[1 ]][ 0 , ], mixed_list_ptype )
489
+ expect_ptype (unsum_pred $ .pred [[1 ]], mixed_list_ptype )
479
490
expect_equal(nrow(unsum_pred $ .pred [[1 ]]), length(time_points ))
480
491
481
492
sum_pred <- collect_predictions(rs_mixed_res , summarize = TRUE )
482
- expect_equal (sum_pred [ 0 ,] , mixed_ptype [, names(mixed_ptype ) != " id" ])
493
+ expect_ptype (sum_pred , mixed_ptype [, names(mixed_ptype ) != " id" ])
483
494
expect_equal(nrow(sum_pred ), nrow(sim_tr ))
484
495
485
- expect_equal (sum_pred $ .pred [[1 ]][ 0 , ], mixed_list_ptype )
496
+ expect_ptype (sum_pred $ .pred [[1 ]], mixed_list_ptype )
486
497
expect_equal(nrow(sum_pred $ .pred [[1 ]]), length(time_points ))
487
498
488
499
# test show_best() -----------------------------------------------------------
0 commit comments