Skip to content

Commit 75c6c03

Browse files
committed
fix claude suggestions
1 parent b7eab0c commit 75c6c03

4 files changed

Lines changed: 30 additions & 3 deletions

File tree

R/check_parallel_cores.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ check_parallel_cores <- function(num_cores) {
1111
c(
1212
"This computer appears to have
1313
{parallel::detectCores()} cores available.
14-
Reducing `num_cores` argument to {num_cores}
14+
`est_seroincidence_by()` has reduced its
15+
`num_cores` argument to {num_cores}
1516
to avoid destabilizing the computer."
1617
)
1718
)

R/sim_pop_data_multi.R

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#' @param lambdas incidence rate, in events/person*year
88
#' @param num_cores number of cores to use for parallel computations
99
#' @param verbose whether to report verbose information
10+
#' @param ... arguments passed to [sim.cs()]
1011
#' @inheritDotParams sim_pop_data
1112
#' @return a [tibble::tibble()]
1213
#' @export
@@ -26,7 +27,32 @@ sim_pop_data_multi <- function(
2627

2728
if (num_cores > 1L) {
2829

30+
chk <- Sys.getenv("_R_CHECK_LIMIT_CORES_", "")
31+
32+
if (nzchar(chk)) {
33+
chk_u <- toupper(chk)
34+
35+
if (chk_u %in% c("TRUE", "T", "YES", "Y")) {
36+
# In check environments, be polite: cap at 2
37+
num_cores <- min(num_cores, 2L)
38+
39+
} else if (chk_u %in% c("FALSE", "F", "NO", "N")) {
40+
# No cap requested
41+
42+
} else {
43+
# Often this is a numeric string like "2"
44+
chk_n <- suppressWarnings(as.integer(chk))
45+
if (!is.na(chk_n) && chk_n >= 1L) {
46+
num_cores <- min(num_cores, chk_n)
47+
} else {
48+
# Unrecognized value: be conservative
49+
num_cores <- min(num_cores, 2L)
50+
}
51+
}
52+
}
53+
2954
# Apply existing safety checker after any cap
55+
3056
num_cores <- num_cores |> check_parallel_cores()
3157

3258
}

cran-comments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## R CMD check results
1212

13-
0 errors | 0 warnings | 2 notes
13+
0 errors | 0 warnings | 1 note
1414

1515
* There are some words flagged by checks as misspelled, but they are listed in `inst/WORDLIST` and are correctly spelled.
1616
* 1 note regarding package archive on 2026-01-16 due to issues not addressed in time. We have addressed these issues in this release.

vignettes/articles/simulate_xsectionalData.qmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ autoplot(est1, log_x = TRUE)
293293

294294
```{r "init-parallel"}
295295
library(parallel)
296-
n_cores <- min(2, parallel::detectCores())
296+
n_cores <- n_cores <- min(2, parallel::detectCores())
297297
print(n_cores)
298298
```
299299

0 commit comments

Comments
 (0)