Skip to content

Commit

Permalink
replace apply with lapply + asplit
Browse files Browse the repository at this point in the history
  • Loading branch information
jsocolar authored Jul 19, 2023
1 parent 645542f commit 2a002e5
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2a002e5

Please sign in to comment.