@@ -580,28 +580,33 @@ test_that("`stat` works", {
580580 } else {
581581 suggsize_seed <- NULL
582582 }
583- # Warnings are suppressed, but a suggested size of `NA` (because of a
584- # search which was terminated too early) is tested below:
583+ # Warnings are suppressed, but a suggested size of nterms_max (because of
584+ # a search which was terminated too early) is tested below:
585585 suggsize <- suppressWarnings(
586586 suggest_size(vss [[tstsetup_vs ]], stat = stat_crr , seed = suggsize_seed )
587587 )
588588 expect_length(suggsize , 1 )
589- if (! is.na(suggsize )) {
590- expect_true(is.vector(suggsize , " numeric" ),
591- info = paste(tstsetup , stat_crr , sep = " __" ))
592- expect_true(suggsize > = 0 , info = paste(tstsetup , stat_crr , sep = " __" ))
593- } else {
594- expect_identical(suggsize , NA ,
595- info = paste(tstsetup , stat_crr , sep = " __" ))
596- expect_true(
597- vss [[tstsetup_vs ]]$ nterms_max < vss [[tstsetup_vs ]]$ nterms_all ,
598- info = paste(tstsetup , stat_crr , sep = " __" )
599- )
600- }
589+ expect_true(is.vector(suggsize , " numeric" ),
590+ info = paste(tstsetup , stat_crr , sep = " __" ))
591+ expect_true(suggsize > = 0 , info = paste(tstsetup , stat_crr , sep = " __" ))
592+ # If the search was terminated early and no submodel satisfies the
593+ # criterion, suggest_size() should return nterms_max:
594+ expect_true(suggsize < = vss [[tstsetup_vs ]]$ nterms_max ,
595+ info = paste(tstsetup , stat_crr , sep = " __" ))
601596 }
602597 }
603598})
604599
600+ test_that(" returns nterms_max when no criterion is met" , {
601+ skip_if_not(run_vs )
602+ tstsetup <- head(names(vss ), 1 )
603+ suggsize <- suppressWarnings(
604+ suggest_size(vss [[tstsetup ]], stat = " elpd" , pct = - 1.0 )
605+ )
606+ expect_identical(suggsize , vss [[tstsetup ]]$ nterms_max ,
607+ info = tstsetup )
608+ })
609+
605610# ranking() ---------------------------------------------------------------
606611
607612context(" ranking()" )
0 commit comments