From 775a070855baaf2f296fab78f7776387123f39fc Mon Sep 17 00:00:00 2001 From: "Jacob B. Socolar" Date: Wed, 19 Jul 2023 12:23:19 -0400 Subject: [PATCH 1/5] replace \ with function --- R/fit.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/fit.R b/R/fit.R index 7bf6ec1b2..498dbd295 100644 --- a/R/fit.R +++ b/R/fit.R @@ -1447,16 +1447,16 @@ loo <- function(variables = "log_lik", r_eff = TRUE, moment_match = FALSE, ...) } log_lik_i_upars <- function(x, upars, i, parameter_name = "log_lik", ...) { - apply(upars, 1, \(up_i) { x$constrain_variables(up_i)[[parameter_name]][i] }) + apply(upars, 1, function(up_i) { x$constrain_variables(up_i)[[parameter_name]][i] }) } loo::loo_moment_match.default( x = self, loo = loo_result, - post_draws = \(x, ...) { x$draws(format = "draws_matrix") }, + post_draws = function(x, ...) { x$draws(format = "draws_matrix") }, log_lik_i = log_lik_i, - unconstrain_pars = \(x, pars, ...) { do.call(rbind, lapply(x$unconstrain_draws(), \(chain) { do.call(rbind, chain) })) }, - log_prob_upars = \(x, upars, ...) { apply(upars, 1, x$log_prob) }, + unconstrain_pars = function(x, pars, ...) { do.call(rbind, lapply(x$unconstrain_draws(), function(chain) { do.call(rbind, chain) })) }, + log_prob_upars = function(x, upars, ...) { apply(upars, 1, x$log_prob) }, log_lik_i_upars = log_lik_i_upars, ... ) From b176b8b981d3080400bde12d4cfdab1da5708b4f Mon Sep 17 00:00:00 2001 From: "Jacob B. Socolar" Date: Wed, 19 Jul 2023 13:35:15 -0400 Subject: [PATCH 2/5] Checking R 3.5 on CI --- .github/workflows/R-CMD-check.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 1ecf76d7a..e2ba4548c 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -31,6 +31,7 @@ jobs: - {os: ubuntu-20.04, r: 'devel', rtools: ''} - {os: ubuntu-20.04, r: 'release', rtools: ''} - {os: ubuntu-20.04, r: 'oldrel', rtools: ''} + - {os: ubuntu-20.04, r: '3.5', rtools: ''} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} From fe8b44980727f34bc191a46cee76208887c92e94 Mon Sep 17 00:00:00 2001 From: "Jacob B. Socolar" Date: Wed, 19 Jul 2023 13:57:13 -0400 Subject: [PATCH 3/5] change \ to function in posterior.rmd --- vignettes/posterior.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/posterior.Rmd b/vignettes/posterior.Rmd index ea9b527ce..3d246a6f1 100644 --- a/vignettes/posterior.Rmd +++ b/vignettes/posterior.Rmd @@ -54,7 +54,7 @@ fit$summary( "median", my_sd, ~quantile(.x, probs = c(0.1, 0.9)), - Minimum = \(x) min(x) + Minimum = function(x) min(x) ) ``` From 645542f878c7865fb2723440bf10751694af2cab Mon Sep 17 00:00:00 2001 From: "Jacob B. Socolar" Date: Wed, 19 Jul 2023 15:21:15 -0400 Subject: [PATCH 4/5] 3.6 rather than 3.5 on CI RcppEigen depends R 3.6 --- .github/workflows/R-CMD-check.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index e2ba4548c..89b10d782 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -31,7 +31,7 @@ jobs: - {os: ubuntu-20.04, r: 'devel', rtools: ''} - {os: ubuntu-20.04, r: 'release', rtools: ''} - {os: ubuntu-20.04, r: 'oldrel', rtools: ''} - - {os: ubuntu-20.04, r: '3.5', rtools: ''} + - {os: ubuntu-20.04, r: '3.6', rtools: ''} env: R_REMOTES_NO_ERRORS_FROM_WARNINGS: true GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} From 2a002e505b0a3a9992c9302c4b8b8cb868851509 Mon Sep 17 00:00:00 2001 From: "Jacob B. Socolar" Date: Wed, 19 Jul 2023 17:56:03 -0400 Subject: [PATCH 5/5] replace apply with lapply + asplit --- R/fit.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/fit.R b/R/fit.R index 498dbd295..0bffa1cc5 100644 --- a/R/fit.R +++ b/R/fit.R @@ -560,10 +560,10 @@ unconstrain_draws <- function(files = NULL, draws = NULL) { generated_quantities = FALSE) par_columns <- !(names(draws) %in% c(".chain", ".iteration", ".draw")) unconstrained <- lapply(split(draws, f = draws$.chain), function(chain) { - apply(chain, 1, function(draw) { + lapply(asplit(chain, 1), function(draw) { par_list <- utils::relist(as.numeric(draw[par_columns]), skeleton) self$unconstrain_variables(variables = par_list) - }, simplify = FALSE) + }) }) } CmdStanFit$set("public", name = "unconstrain_draws", value = unconstrain_draws)