diff --git a/NEWS.md b/NEWS.md index f750359..68596f2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,6 +4,9 @@ * dramatically improved efficiency in certain post-processing functions for multiseason models * CI runs properly * backend hygiene improvements +* updated compatibility with upcoming changes to `loo_compare()` output + structure in the `loo` package (> 2.9.0), which now returns a data frame + instead of a matrix and includes additional diagnostic columns. # flocker 1.0-1 * fixed a bug that was throwing an uninformative error when making predictions in multiseason models where history_condition is TRUE diff --git a/R/loo.R b/R/loo.R index 77918f3..f592b96 100644 --- a/R/loo.R +++ b/R/loo.R @@ -63,7 +63,7 @@ loo_flocker_onefit <- function(x, thin = NULL) { #' @param thin specify the amount of thinning required. 1 or NULL results in no #' thinning, 2 retains every other value, 3 every third, etc. #' @param model_names An optional vector of names for the models. -#' @return a `compare.loo` matrix +#' @return a `compare.loo` object #' @export #' @examples #' \dontrun{ diff --git a/man/loo_compare_flocker.Rd b/man/loo_compare_flocker.Rd index d5faaa5..fec16d8 100644 --- a/man/loo_compare_flocker.Rd +++ b/man/loo_compare_flocker.Rd @@ -15,7 +15,7 @@ loo_compare_flocker(model_list, model_names = NULL, thin = NULL) thinning, 2 retains every other value, 3 every third, etc.} } \value{ -a `compare.loo` matrix +a `compare.loo` object } \description{ LOO comparisons for flocker models. diff --git a/tests/testthat/test-loo_flocker.R b/tests/testthat/test-loo_flocker.R index d095e76..d846024 100644 --- a/tests/testthat/test-loo_flocker.R +++ b/tests/testthat/test-loo_flocker.R @@ -43,8 +43,16 @@ test_that("loo_compare_flocker works correctly", { # check model naming suppressWarnings(test_compare <- loo_compare_flocker(list(example_flocker_model_single2, example_flocker_model_single2), model_names = c("m1", "m2"), thin = 2)) - expect_identical(row.names(test_compare), c("m1", "m2")) + if ("model" %in% colnames(test_compare)) { + expect_identical(test_compare$model, c("m1", "m2")) + } else { + expect_identical(row.names(test_compare), c("m1", "m2")) + } # check test output identical - expect_true(all(apply(test_compare, 2, diff) == 0)) + if ("model" %in% colnames(test_compare)) { + expect_true(all(apply(test_compare[,c(2,3)], 2, diff) == 0)) + } else { + expect_true(all(apply(test_compare, 2, diff) == 0)) + } })