diff --git a/DESCRIPTION b/DESCRIPTION index 7c5ef3d..a6289bf 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: posterior Title: Tools for Working with Posterior Distributions -Version: 1.6.0.9000 -Date: 2024-12-02 +Version: 1.6.0 +Date: 2024-06-28 Authors@R: c(person("Paul-Christian", "Bürkner", email = "paul.buerkner@gmail.com", role = c("aut", "cre")), person("Jonah", "Gabry", email = "jsg2201@columbia.edu", role = c("aut")), person("Matthew", "Kay", email = "mjskay@northwestern.edu", role = c("aut")), diff --git a/NEWS.md b/NEWS.md index 0ca3d52..7ae17cd 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,9 +1,3 @@ -# posterior 1.6.0+ - -### Enhancements - -* Convert lists of matrices to `draws_array` objects. - # posterior 1.6.0 ### Enhancements diff --git a/R/as_draws.R b/R/as_draws.R index 84c4e66..c52e75a 100644 --- a/R/as_draws.R +++ b/R/as_draws.R @@ -76,11 +76,10 @@ closest_draws_format <- function(x) { out <- "rvars" } else if (is_draws_list_like(x)) { out <- "list" - } else { - stop_no_call( - "Don't know how to transform an object of class '", - class(x)[1L], "' to any supported draws format." - ) + } + else { + stop_no_call("Don't know how to transform an object of class ", + "'", class(x)[1L], "' to any supported draws format.") } paste0("draws_", out) } diff --git a/R/as_draws_array.R b/R/as_draws_array.R index cfe263b..ab123a4 100644 --- a/R/as_draws_array.R +++ b/R/as_draws_array.R @@ -130,11 +130,7 @@ as_draws_array.mcmc.list <- function(x, ...) { # try to convert any R object into a 'draws_array' object .as_draws_array <- function(x) { - if (is_matrix_list_like(x)) { - x <- as_array_matrix_list(x) - } else { - x <- as.array(x) - } + x <- as.array(x) new_dimnames <- list(iteration = NULL, chain = NULL, variable = NULL) if (!is.null(dimnames(x)[[3]])) { new_dimnames[[3]] <- dimnames(x)[[3]] @@ -181,14 +177,7 @@ is_draws_array <- function(x) { # is an object looking like a 'draws_array' object? is_draws_array_like <- function(x) { - is.array(x) && length(dim(x)) == 3L || - is_matrix_list_like(x) -} - -# is an object likely a list of matrices? -# such an object can be easily converted to a draws_array -is_matrix_list_like <- function(x) { - is.list(x) && length(dim(x[[1]])) == 2L + is.array(x) && length(dim(x)) == 3L } #' Extract parts of a `draws_array` object