diff --git a/src/alg_reg_policies.h b/src/alg_reg_policies.h index 47faa68..adad2df 100644 --- a/src/alg_reg_policies.h +++ b/src/alg_reg_policies.h @@ -52,7 +52,7 @@ class AlgorithmicRegularizationFixedStepSizePolicy { } if(iter >= max_iter){ - ClustRVizLogger::warning("Clustering ended early -- `max_iter` reached. Treat results with caution."); + ClustRVizLogger::error("Clustering ended early -- `max_iter` reached. Treat results with caution."); } solved = true; @@ -204,7 +204,7 @@ class AlgorithmicRegularizationBacktrackingPolicy { } if(iter >= max_iter){ - ClustRVizLogger::warning("Clustering ended early -- `max_iter` reached. Treat results with caution."); + ClustRVizLogger::error("Clustering ended early -- `max_iter` reached. Treat results with caution."); } solved = true; diff --git a/src/optim_policies.h b/src/optim_policies.h index f3482bf..2d1c3ad 100644 --- a/src/optim_policies.h +++ b/src/optim_policies.h @@ -55,7 +55,7 @@ class ADMMPolicy { } if(iter >= max_iter){ - ClustRVizLogger::warning("Clustering ended early -- `max_iter` reached. Treat results with caution."); + ClustRVizLogger::error("Clustering ended early -- `max_iter` reached. Treat results with caution."); } solved = true; @@ -202,7 +202,7 @@ class BackTrackingADMMPolicy { } if(iter >= max_iter){ - ClustRVizLogger::warning("Clustering ended early -- `max_iter` reached. Treat results with caution."); + ClustRVizLogger::error("Clustering ended early -- `max_iter` reached. Treat results with caution."); } solved = true; diff --git a/tests/testthat/test_carp_misc.R b/tests/testthat/test_carp_misc.R index fdffd3b..01b2a92 100644 --- a/tests/testthat/test_carp_misc.R +++ b/tests/testthat/test_carp_misc.R @@ -30,3 +30,10 @@ test_that("CARP stores scale factors", { expect_equal(carp_fit_no_std$scale_vector, rep(1, NCOL(presidential_speech))) expect_equal(carp_fit_no_std$center_vector, rep(0, NCOL(presidential_speech))) }) + +test_that("CARP fails when max_iter reached", { + clustRviz_options(max_iter = 400) + on.exit(clustRviz_reset_options()) + + expect_error(CARP(presidential_speech), "Clustering ended early") +}) diff --git a/tests/testthat/test_cbass_misc.R b/tests/testthat/test_cbass_misc.R index ef48a74..b3de41a 100644 --- a/tests/testthat/test_cbass_misc.R +++ b/tests/testthat/test_cbass_misc.R @@ -30,3 +30,12 @@ test_that("CBASS stores mean of original data", { cbass_fit <- CBASS(presidential_speech, X.center.global = FALSE) expect_equal(0, cbass_fit$mean_adjust) }) + + +test_that("CBASS fails when max_iter reached", { + clustRviz_options(max_iter = 400) + on.exit(clustRviz_reset_options()) + + expect_error(CBASS(presidential_speech), "Clustering ended early") +}) +