From b977fcc4fee2c81707bddc44865bd70c8d747855 Mon Sep 17 00:00:00 2001 From: Jenna Li Date: Sat, 13 Jun 2026 20:50:31 +0100 Subject: [PATCH 01/13] Add manual progress fallback when progress package unavailable. When show_progress_bar = TRUE but the progress package is not installed, rather than silently doing nothing, emit a one-time warning then print 10%-interval progress messages with elapsed time to the console. Changes in R/chains.R: - Add is_package_available() wrapper around requireNamespace() to allow mocking in tests - Replace single use_progress_bar boolean with two separate booleans (show_progress_bar, progress_available) passed through sample_chain() and chain_loop(), keeping the two concerns distinct - Print upfront message in sample_chain() when progress package is missing but progress bar was requested - Update get_progress_bar() signature to accept the two booleans - Add start_time tracking in chain_loop() using proc.time() - Add fallback else-if branch in chain_loop() printing formatted percentage/elapsed messages at 10% intervals - Add post-loop guard to print 100% done when n_iteration is not a multiple of tick_amount - Update @param show_progress_bar roxygen doc to reflect new behaviour Changes in tests/testthat/test-chains.R: - Add make_fallback_test_inputs() helper to deduplicate test setup - Add test verifying fallback messages are emitted (count, 10%, 100%) - Add test verifying no messages when show_progress_bar = FALSE --- R/chains.R | 50 ++++++++++++++++++++++++------ tests/testthat/test-chains.R | 60 ++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 10 deletions(-) diff --git a/R/chains.R b/R/chains.R index 43d0f48..fad5146 100644 --- a/R/chains.R +++ b/R/chains.R @@ -56,8 +56,9 @@ #' coerce the average acceptance rate to a target value using a dual-averaging #' algorithm, and adapting the shape to an estimate of the covariance of the #' target distribution. -#' @param show_progress_bar Whether to show progress bars during sampling. -#' Requires `progress` package to be installed to have an effect. +#' @param show_progress_bar Whether to show progress bars during sampling. If the +#' `progress` package is installed, displays a progress bar; otherwise prints +#' periodic progress messages to the console. #' @param trace_warm_up Whether to record chain traces and adaptation / #' transition statistics during (adaptive) warm-up iterations in addition to #' (non-adaptive) main chain iterations. @@ -103,8 +104,12 @@ sample_chain <- function( show_progress_bar = TRUE, trace_warm_up = FALSE ) { - progress_available <- requireNamespace("progress", quietly = TRUE) - use_progress_bar <- progress_available && show_progress_bar + progress_available <- is_package_available("progress") + if (show_progress_bar && !progress_available) { + message( + "progress package is not installed, so will print progress updates below." + ) + } initial_state <- check_and_process_initial_state(initial_state) target_distribution <- check_and_process_target_distribution( target_distribution @@ -118,7 +123,8 @@ sample_chain <- function( target_distribution = target_distribution, proposal = proposal, adapters = adapters, - use_progress_bar = use_progress_bar, + show_progress_bar = show_progress_bar, + progress_available = progress_available, record_traces_and_statistics = trace_warm_up, trace_function = trace_function, statistic_names = statistic_names @@ -130,7 +136,8 @@ sample_chain <- function( target_distribution = target_distribution, proposal = proposal, adapters = NULL, - use_progress_bar = use_progress_bar, + show_progress_bar = show_progress_bar, + progress_available = progress_available, record_traces_and_statistics = TRUE, trace_function = trace_function, statistic_names = statistic_names @@ -184,11 +191,13 @@ default_trace_function <- function(target_distribution) { } } -get_progress_bar <- function(use_progress_bar, n_iteration, label) { +is_package_available <- function(pkg) requireNamespace(pkg, quietly = TRUE) + +get_progress_bar <- function(show_progress_bar, progress_available, n_iteration, label) { progress_bar_format <- ( "%s :percent |:bar| :current/:total [:elapsed<:eta] :tick_rate it/s" ) - if (use_progress_bar) { + if (show_progress_bar && progress_available) { progress::progress_bar$new( format = sprintf(progress_bar_format, label), total = n_iteration, @@ -244,12 +253,15 @@ chain_loop <- function( target_distribution, proposal, adapters, - use_progress_bar, + show_progress_bar, + progress_available, record_traces_and_statistics, trace_function, statistic_names ) { - progress_bar <- get_progress_bar(use_progress_bar, n_iteration, stage_name) + progress_bar <- get_progress_bar( + show_progress_bar, progress_available, n_iteration, stage_name + ) # Only show 10% increments in progress bar to avoid progress bar updates being # a bottleneck when chain iteration rate is high tick_amount <- max(n_iteration %/% 10, 1) @@ -261,6 +273,7 @@ chain_loop <- function( traces <- NULL statistics <- NULL } + start_time <- proc.time()[["elapsed"]] for (chain_iteration in seq_len(n_iteration)) { state_and_statistics <- sample_metropolis_hastings( state, target_distribution, proposal @@ -276,11 +289,28 @@ chain_loop <- function( } if (!is.null(progress_bar) && (chain_iteration %% tick_amount == 0)) { progress_bar$tick(tick_amount) + } else if ( # fallback: manual progress updates + show_progress_bar && !progress_available && + (chain_iteration %% tick_amount == 0) + ) { + elapsed <- proc.time()[["elapsed"]] - start_time + pct <- round(100 * chain_iteration / n_iteration) + message(sprintf( + "%s: %d%% done (%d/%d iterations) | elapsed: %.1fs", + stage_name, pct, chain_iteration, n_iteration, elapsed + )) } } # Ensure progress bar shows completed in cases tick_amount not a factor of # n_iteration if (!is.null(progress_bar) && !progress_bar$finished) progress_bar$update(1) + if (show_progress_bar && !progress_available && n_iteration > 0 && (n_iteration %% tick_amount != 0)) { + elapsed <- proc.time()[["elapsed"]] - start_time + message(sprintf( + "%s: 100%% done (%d/%d iterations) | elapsed: %.1fs", + stage_name, n_iteration, n_iteration, elapsed + )) + } finalize_adapters(adapters, proposal) list(final_state = state, traces = traces, statistics = statistics) } diff --git a/tests/testthat/test-chains.R b/tests/testthat/test-chains.R index 38c2809..6e7a1cd 100644 --- a/tests/testthat/test-chains.R +++ b/tests/testthat/test-chains.R @@ -113,3 +113,63 @@ test_that("Sample chains with invalid target_distribution raises error", { "target_distribution" ) }) + +make_fallback_test_inputs <- function() { + target_distribution <- standard_normal_target_distribution() + adapters <- list(scale_adapter("stochastic_approximation", initial_scale = 1.)) + withr::with_seed(default_seed(), { + position <- rnorm(2) + }) + list( + target_distribution = target_distribution, + adapters = adapters, + position = position + ) +} + +test_that("Manual progress fallback prints messages when progress unavailable", { + inputs <- make_fallback_test_inputs() + # Simulate progress package being unavailable by mocking requireNamespace + with_mocked_bindings( + is_package_available = function(pkg) FALSE, + .package = "rmcmc", + { + msgs <- capture_messages( + sample_chain( + target_distribution = inputs$target_distribution, + initial_state = inputs$position, + n_warm_up_iteration = 10, + n_main_iteration = 10, + adapters = inputs$adapters, + show_progress_bar = TRUE + ) + ) + } + ) + # 1 upfront warning + 10 interval messages per stage (warm-up + main) + # = 1 + 10 + 10 = 21 messages total + expect_length(msgs, 21) + expect_true(any(grepl("progress package is not installed", msgs))) + expect_true(any(grepl("10%", msgs))) + expect_true(any(grepl("100%", msgs))) +}) + +test_that("No manual progress output when show_progress_bar is FALSE", { + inputs <- make_fallback_test_inputs() + with_mocked_bindings( + is_package_available = function(pkg) FALSE, + .package = "rmcmc", + { + expect_no_message( + sample_chain( + target_distribution = inputs$target_distribution, + initial_state = inputs$position, + n_warm_up_iteration = 10, + n_main_iteration = 10, + adapters = inputs$adapters, + show_progress_bar = FALSE + ) + ) + } + ) +}) From c752dbbdde98ca8f330aec3629a03ea29a48d91e Mon Sep 17 00:00:00 2001 From: Jenna Jia Li <139101659+jennajiali@users.noreply.github.com> Date: Thu, 18 Jun 2026 12:13:11 +0100 Subject: [PATCH 02/13] Update R/chains.R to resolve linter indentation warning The linter warning here is due to indentation. We can avoid need to split line and repetition of chain_iteration %% tick_amount == 0 expression by factoring out in to a variable and reusing. We also don't need to explicitly check !progress_available in second condition as this is implied by the fact first condition didn't evaluate to TRUE. Co-authored-by: Matt Graham --- R/chains.R | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/R/chains.R b/R/chains.R index fad5146..690895b 100644 --- a/R/chains.R +++ b/R/chains.R @@ -287,12 +287,10 @@ chain_loop <- function( c(state_and_statistics$statistics, adapter_states) ) } - if (!is.null(progress_bar) && (chain_iteration %% tick_amount == 0)) { + do_tick <- chain_iteration %% tick_amount == 0 + if (!is.null(progress_bar) && do_tick) { progress_bar$tick(tick_amount) - } else if ( # fallback: manual progress updates - show_progress_bar && !progress_available && - (chain_iteration %% tick_amount == 0) - ) { + } else if (show_progress_bar && do_tick) { # fallback progress updates elapsed <- proc.time()[["elapsed"]] - start_time pct <- round(100 * chain_iteration / n_iteration) message(sprintf( From 25bc5640e9f316d616ceb5596461a2ca0b37f8a6 Mon Sep 17 00:00:00 2001 From: Jenna Jia Li <139101659+jennajiali@users.noreply.github.com> Date: Thu, 18 Jun 2026 12:15:48 +0100 Subject: [PATCH 03/13] Update R/chains.R to fix linter line length warning Reflowing this line should fix linter line length warning. Co-authored-by: Matt Graham --- R/chains.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/chains.R b/R/chains.R index 690895b..eb9da00 100644 --- a/R/chains.R +++ b/R/chains.R @@ -193,7 +193,9 @@ default_trace_function <- function(target_distribution) { is_package_available <- function(pkg) requireNamespace(pkg, quietly = TRUE) -get_progress_bar <- function(show_progress_bar, progress_available, n_iteration, label) { +get_progress_bar <- function( + show_progress_bar, progress_available, n_iteration, label +) { progress_bar_format <- ( "%s :percent |:bar| :current/:total [:elapsed<:eta] :tick_rate it/s" ) From 8da168060ed0af243b28c79ca25d0d1a19b3c8ba Mon Sep 17 00:00:00 2001 From: Jenna Li Date: Thu, 18 Jun 2026 12:30:30 +0100 Subject: [PATCH 04/13] Update man/sample_chain.Rd with the new version of roxygen comment by running devtools::document() --- man/sample_chain.Rd | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/man/sample_chain.Rd b/man/sample_chain.Rd index 4e7c774..3a11f99 100644 --- a/man/sample_chain.Rd +++ b/man/sample_chain.Rd @@ -76,8 +76,9 @@ coerce the average acceptance rate to a target value using a dual-averaging algorithm, and adapting the shape to an estimate of the covariance of the target distribution.} -\item{show_progress_bar}{Whether to show progress bars during sampling. -Requires \code{progress} package to be installed to have an effect.} +\item{show_progress_bar}{Whether to show progress bars during sampling. If the +\code{progress} package is installed, displays a progress bar; otherwise prints +periodic progress messages to the console.} \item{trace_warm_up}{Whether to record chain traces and adaptation / transition statistics during (adaptive) warm-up iterations in addition to From 835b8ab83e2b88b191058f6c5dfb900edad36c58 Mon Sep 17 00:00:00 2001 From: Jenna Li Date: Thu, 18 Jun 2026 12:48:12 +0100 Subject: [PATCH 05/13] Refactor progress_bar if-elseif condition to improve readability and resolve linter warning To reduce line length to avoid linter warning here and make code more readable we can define a variable progress_unfinished which checks whether progress updates are complete and then use this in conditions. We ideally also want to use else if here rather than an independent if clause as we don't need to check the second condition if the first evaluates to TRUE. This also suggests changing progress$finished to use progress_unfinished variable as this should be functionally equivalent and makes it clear we are using the same condition irrespective of whether using the progress package or not. --- R/chains.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/R/chains.R b/R/chains.R index eb9da00..7e4b608 100644 --- a/R/chains.R +++ b/R/chains.R @@ -303,8 +303,10 @@ chain_loop <- function( } # Ensure progress bar shows completed in cases tick_amount not a factor of # n_iteration - if (!is.null(progress_bar) && !progress_bar$finished) progress_bar$update(1) - if (show_progress_bar && !progress_available && n_iteration > 0 && (n_iteration %% tick_amount != 0)) { + progress_unfinished <- n_iteration > 0 && (n_iteration %% tick_amount != 0) + if (!is.null(progress_bar) && progress_unfinished) { + progress_bar$update(1) + } else if (show_progress_bar && !progress_available && progress_unfinished) { elapsed <- proc.time()[["elapsed"]] - start_time message(sprintf( "%s: 100%% done (%d/%d iterations) | elapsed: %.1fs", From e902926b3d03c8fa928642c490dd36a177495f1e Mon Sep 17 00:00:00 2001 From: Jenna Li Date: Thu, 18 Jun 2026 13:46:59 +0100 Subject: [PATCH 06/13] Wrapped the repeated code into print_fallback_progress(); Tightened the scope of the mock_bindings --- R/chains.R | 32 +++++++++++++++++++------------- tests/testthat/test-chains.R | 6 +++--- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/R/chains.R b/R/chains.R index 7e4b608..ac79c19 100644 --- a/R/chains.R +++ b/R/chains.R @@ -104,7 +104,7 @@ sample_chain <- function( show_progress_bar = TRUE, trace_warm_up = FALSE ) { - progress_available <- is_package_available("progress") + progress_available <- is_progress_package_available() if (show_progress_bar && !progress_available) { message( "progress package is not installed, so will print progress updates below." @@ -193,6 +193,19 @@ default_trace_function <- function(target_distribution) { is_package_available <- function(pkg) requireNamespace(pkg, quietly = TRUE) +is_progress_package_available <- function() is_package_available("progress") + +print_fallback_progress <- function( + stage_name, chain_iteration, n_iteration, start_time +) { + elapsed <- proc.time()[["elapsed"]] - start_time + pct <- round(100 * chain_iteration / n_iteration) + message(sprintf( + "%s: %d%% done (%d/%d iterations) | elapsed: %.1fs", + stage_name, pct, chain_iteration, n_iteration, elapsed + )) +} + get_progress_bar <- function( show_progress_bar, progress_available, n_iteration, label ) { @@ -292,13 +305,10 @@ chain_loop <- function( do_tick <- chain_iteration %% tick_amount == 0 if (!is.null(progress_bar) && do_tick) { progress_bar$tick(tick_amount) - } else if (show_progress_bar && do_tick) { # fallback progress updates - elapsed <- proc.time()[["elapsed"]] - start_time - pct <- round(100 * chain_iteration / n_iteration) - message(sprintf( - "%s: %d%% done (%d/%d iterations) | elapsed: %.1fs", - stage_name, pct, chain_iteration, n_iteration, elapsed - )) + } else if (show_progress_bar && do_tick) { # fallback progress updates + print_fallback_progress( + stage_name, chain_iteration, n_iteration, start_time + ) } } # Ensure progress bar shows completed in cases tick_amount not a factor of @@ -307,11 +317,7 @@ chain_loop <- function( if (!is.null(progress_bar) && progress_unfinished) { progress_bar$update(1) } else if (show_progress_bar && !progress_available && progress_unfinished) { - elapsed <- proc.time()[["elapsed"]] - start_time - message(sprintf( - "%s: 100%% done (%d/%d iterations) | elapsed: %.1fs", - stage_name, n_iteration, n_iteration, elapsed - )) + print_fallback_progress(stage_name, n_iteration, n_iteration, start_time) } finalize_adapters(adapters, proposal) list(final_state = state, traces = traces, statistics = statistics) diff --git a/tests/testthat/test-chains.R b/tests/testthat/test-chains.R index 6e7a1cd..e42d64b 100644 --- a/tests/testthat/test-chains.R +++ b/tests/testthat/test-chains.R @@ -129,9 +129,9 @@ make_fallback_test_inputs <- function() { test_that("Manual progress fallback prints messages when progress unavailable", { inputs <- make_fallback_test_inputs() - # Simulate progress package being unavailable by mocking requireNamespace + # Simulate progress package being unavailable by mocking with_mocked_bindings( - is_package_available = function(pkg) FALSE, + is_progress_package_available = function() FALSE, .package = "rmcmc", { msgs <- capture_messages( @@ -157,7 +157,7 @@ test_that("Manual progress fallback prints messages when progress unavailable", test_that("No manual progress output when show_progress_bar is FALSE", { inputs <- make_fallback_test_inputs() with_mocked_bindings( - is_package_available = function(pkg) FALSE, + is_progress_package_available = function() FALSE, .package = "rmcmc", { expect_no_message( From 87331008db22e9cbafb9b7cad6b2460a60a01878 Mon Sep 17 00:00:00 2001 From: Jenna Jia Li <139101659+jennajiali@users.noreply.github.com> Date: Thu, 18 Jun 2026 21:52:43 +0100 Subject: [PATCH 07/13] Add nolint comment next to chain_loop to ignore cyclocomp linter warning This will cause the linter warning on cyclomatic complexity for this function to be ignored. As per the comment below it's not clear how useful the cyclomatic complexity measure is here so we may want to consider disabling globally, and either way I think it is justified to ignore it for now here and potentially consider possible refactorings to reduce complexity of this function in a separate PR. Co-authored-by: Matt Graham --- R/chains.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/chains.R b/R/chains.R index ac79c19..ee079dc 100644 --- a/R/chains.R +++ b/R/chains.R @@ -261,7 +261,7 @@ finalize_adapters <- function(adapters, proposal) { invisible(adapters) } -chain_loop <- function( +chain_loop <- function( # nolint: cyclocomp_linter stage_name, n_iteration, state, From 9cc09878516368d2f39a742fa081469206285667 Mon Sep 17 00:00:00 2001 From: Jenna Jia Li <139101659+jennajiali@users.noreply.github.com> Date: Thu, 18 Jun 2026 21:56:04 +0100 Subject: [PATCH 08/13] Remove redundant `!progress_available` condition Co-authored-by: Matt Graham --- R/chains.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/chains.R b/R/chains.R index ee079dc..e9f06c0 100644 --- a/R/chains.R +++ b/R/chains.R @@ -316,7 +316,7 @@ chain_loop <- function( # nolint: cyclocomp_linter progress_unfinished <- n_iteration > 0 && (n_iteration %% tick_amount != 0) if (!is.null(progress_bar) && progress_unfinished) { progress_bar$update(1) - } else if (show_progress_bar && !progress_available && progress_unfinished) { + } else if (show_progress_bar && progress_unfinished) { print_fallback_progress(stage_name, n_iteration, n_iteration, start_time) } finalize_adapters(adapters, proposal) From f1404806137064b3d247994cf9a732267799aa54 Mon Sep 17 00:00:00 2001 From: Jenna Jia Li <139101659+jennajiali@users.noreply.github.com> Date: Thu, 18 Jun 2026 21:57:56 +0100 Subject: [PATCH 09/13] Update tests/testthat/test-chains.R to include the case when `n_iteration %% tick_amount != 0` Using a number of iterations which is not an exact multiple of 10 here will ensure the final conditions which ensure progress updates are completed when n_iteration %% tick_amount != 0 are entered as part of the tests and so avoid the warning about that line of code not being covered by tests from codecov check. Co-authored-by: Matt Graham --- tests/testthat/test-chains.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/testthat/test-chains.R b/tests/testthat/test-chains.R index e42d64b..e24b191 100644 --- a/tests/testthat/test-chains.R +++ b/tests/testthat/test-chains.R @@ -129,6 +129,9 @@ make_fallback_test_inputs <- function() { test_that("Manual progress fallback prints messages when progress unavailable", { inputs <- make_fallback_test_inputs() + n_warm_up_iteration <- 10 + # use non-multiple of 10 to test finalisation of progress updates + n_main_iteration <- 11 # Simulate progress package being unavailable by mocking with_mocked_bindings( is_progress_package_available = function() FALSE, @@ -138,17 +141,16 @@ test_that("Manual progress fallback prints messages when progress unavailable", sample_chain( target_distribution = inputs$target_distribution, initial_state = inputs$position, - n_warm_up_iteration = 10, - n_main_iteration = 10, + n_warm_up_iteration = n_warm_up_iteration, + n_main_iteration = n_main_iteration, adapters = inputs$adapters, show_progress_bar = TRUE ) ) } ) - # 1 upfront warning + 10 interval messages per stage (warm-up + main) - # = 1 + 10 + 10 = 21 messages total - expect_length(msgs, 21) + # 1 upfront warning + 1 messages per iteration (warm-up + main) + expect_length(msgs, 1 + n_warm_up_iteration + n_main_iteration) expect_true(any(grepl("progress package is not installed", msgs))) expect_true(any(grepl("10%", msgs))) expect_true(any(grepl("100%", msgs))) From 37d93fb930d00f832c5f1d01611b671056cb156a Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Mon, 22 Jun 2026 17:14:35 +0100 Subject: [PATCH 10/13] Reflow nolint comment to satisfy styler --- R/chains.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/chains.R b/R/chains.R index e9f06c0..c054561 100644 --- a/R/chains.R +++ b/R/chains.R @@ -261,7 +261,8 @@ finalize_adapters <- function(adapters, proposal) { invisible(adapters) } -chain_loop <- function( # nolint: cyclocomp_linter +chain_loop <- function( + # nolint: cyclocomp_linter stage_name, n_iteration, state, From b21916c45896ce4c86123054eb37c39f2191eb20 Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Mon, 22 Jun 2026 17:15:45 +0100 Subject: [PATCH 11/13] Update progress fallback test to hit final condition --- tests/testthat/test-chains.R | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-chains.R b/tests/testthat/test-chains.R index e24b191..68f4224 100644 --- a/tests/testthat/test-chains.R +++ b/tests/testthat/test-chains.R @@ -131,7 +131,7 @@ test_that("Manual progress fallback prints messages when progress unavailable", inputs <- make_fallback_test_inputs() n_warm_up_iteration <- 10 # use non-multiple of 10 to test finalisation of progress updates - n_main_iteration <- 11 + n_main_iteration <- 21 # Simulate progress package being unavailable by mocking with_mocked_bindings( is_progress_package_available = function() FALSE, @@ -149,8 +149,16 @@ test_that("Manual progress fallback prints messages when progress unavailable", ) } ) - # 1 upfront warning + 1 messages per iteration (warm-up + main) - expect_length(msgs, 1 + n_warm_up_iteration + n_main_iteration) + expected_n_progress_messages <- function(n_iteration) { + tick_amount <- max(n_iteration %/% 10, 1) + n_iteration %/% tick_amount + (n_iteration %% tick_amount != 0) + } + # 1 upfront warning + n_iteration dependent number of messages (warm-up + main) + expect_length( + msgs, + 1 + expected_n_progress_messages(n_warm_up_iteration) + + expected_n_progress_messages(n_main_iteration) + ) expect_true(any(grepl("progress package is not installed", msgs))) expect_true(any(grepl("10%", msgs))) expect_true(any(grepl("100%", msgs))) From e5e8e57bba39eb7051111176488fbb9bec143c9e Mon Sep 17 00:00:00 2001 From: Matt Graham Date: Mon, 22 Jun 2026 17:16:48 +0100 Subject: [PATCH 12/13] Add extra test case to cover progress bar finalisation --- tests/testthat/test-chains.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-chains.R b/tests/testthat/test-chains.R index 68f4224..94edc70 100644 --- a/tests/testthat/test-chains.R +++ b/tests/testthat/test-chains.R @@ -1,5 +1,5 @@ for (n_warm_up_iteration in c(0, 1, 10)) { - for (n_main_iteration in c(0, 1, 10)) { + for (n_main_iteration in c(0, 1, 10, 21)) { for (dimension in c(1, 2)) { for (trace_warm_up in c(TRUE, FALSE)) { for (show_progress_bar in c(TRUE, FALSE)) { From b6dc6b0e2fe5102d09d4579e9ac985a22eb11c3b Mon Sep 17 00:00:00 2001 From: Jenna Jia Li <139101659+jennajiali@users.noreply.github.com> Date: Thu, 25 Jun 2026 16:19:43 +0100 Subject: [PATCH 13/13] Update R/chains.R to fix linter warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤞 this will resolve both the styler warning (which wants this comment to be on a separate line) and the linter warning (which requires the nolint directive to be on the line used to open the function) by disabling styler for this specific line. Running both styler and lintr checks locally with this change doesn't raise any warnings. Co-authored-by: Matt Graham --- R/chains.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/R/chains.R b/R/chains.R index c054561..4c867e8 100644 --- a/R/chains.R +++ b/R/chains.R @@ -261,8 +261,7 @@ finalize_adapters <- function(adapters, proposal) { invisible(adapters) } -chain_loop <- function( - # nolint: cyclocomp_linter +chain_loop <- function( # nolint: cyclocomp_linter. styler: off stage_name, n_iteration, state,