From 52534412f38648121188845517c6fcf4121f656b Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 31 May 2024 10:24:23 +0200 Subject: [PATCH 01/14] Prepare CRAN submission --- DESCRIPTION | 2 +- NEWS.md | 6 +++++- tests/testthat/test-fixest.R | 1 + 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 8f4a23d7a5..687d1ef555 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: insight Title: Easy Access to Model Information for Various Model Objects -Version: 0.19.11.5 +Version: 0.20.0 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/NEWS.md b/NEWS.md index 6cc1920b3b..3f06b92be2 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# insight 0.19.12 +# insight 0.20.0 ## Breaking @@ -10,6 +10,10 @@ * `get_datagrid()` * `print_parameters()` +## Bug fixes + +* Fixed errors in CRAN checks. + # insight 0.19.11 ## General diff --git a/tests/testthat/test-fixest.R b/tests/testthat/test-fixest.R index 4bf6cb0a82..43642b7483 100644 --- a/tests/testthat/test-fixest.R +++ b/tests/testthat/test-fixest.R @@ -1,3 +1,4 @@ +# Currently doesn't work on devel - potential fixest issue? skip_if(TRUE) skip_on_os("mac") From 9a1c851cea80fb908043f80df6a74012c35a542f Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 31 May 2024 10:29:01 +0200 Subject: [PATCH 02/14] cran comments --- cran-comments.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cran-comments.md b/cran-comments.md index 987c7ad068..2a0bcc7cf5 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1 +1,9 @@ -This release is required for the planned update of the 'parameters' package, which will be released once 'insight' is on CRAN. The 'parameters' update fixes errors in CRAN checks. +This release fixes errors in CRAN checks. + +Additionally, in the process of stabilizing the API/user interface for packages +from the 'easystats' project, some argument names were renamed and old names +deprecated. This will *not* break downstream dependent packages, however, +reverse-dependency checks will raise warnings. We have already patched all +affected downstream packages and will submit them to CRAN in the next few days, +after the release of 'insight'. Once this release-cycle is complete, all +warnings due to deprecated argument names will be resolved. \ No newline at end of file From 6c86c367946527afac50570e1c882974135b6fd6 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 31 May 2024 10:29:50 +0200 Subject: [PATCH 03/14] comments --- cran-comments.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index 2a0bcc7cf5..8ff8b06064 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,8 +2,8 @@ This release fixes errors in CRAN checks. Additionally, in the process of stabilizing the API/user interface for packages from the 'easystats' project, some argument names were renamed and old names -deprecated. This will *not* break downstream dependent packages, however, +have been deprecated. This will *not break* downstream dependent packages, however, reverse-dependency checks will raise warnings. We have already patched all affected downstream packages and will submit them to CRAN in the next few days, after the release of 'insight'. Once this release-cycle is complete, all -warnings due to deprecated argument names will be resolved. \ No newline at end of file +warnings due to deprecated argument names should be resolved. \ No newline at end of file From 85eb328a148caefd0f6b1aa427d29daaa80395de Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Sat, 1 Jun 2024 08:49:14 -0400 Subject: [PATCH 04/14] Fix compact_list() for labelled + other vctrs classes Closes https://github.com/easystats/performance/issues/727 --- R/utils_compact.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils_compact.R b/R/utils_compact.R index 724b72672c..bd70a659c7 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -10,9 +10,9 @@ #' @export compact_list <- function(x, remove_na = FALSE) { if (remove_na) { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(i == "NULL", na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(sapply(i, identical, y = "NULL"), na.rm = TRUE)))] } else { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(i == "NULL", na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(sapply(i, identical, y = "NULL"), na.rm = TRUE)))] } } From 584bca9e0818cd5849f2df1490adfccf421983e4 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 2 Jun 2024 18:37:09 +0200 Subject: [PATCH 05/14] fix --- R/get_response.R | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/R/get_response.R b/R/get_response.R index a6ddfcee92..2e6a0e0dbb 100644 --- a/R/get_response.R +++ b/R/get_response.R @@ -75,6 +75,11 @@ get_response.default <- function(x, select = NULL, as_proportion = TRUE, source !is.matrix(response)) { response <- as.vector(response) } + + # clear vctr-class attributes + if (inherits(response, "vctrs_vctr")) { + class(response) <- setdiff(class(response), c("haven_labelled", "vctrs_vctr")) + } response } From 45499b100ee6438a31cb15dbe20eb358bcca83a3 Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Jun 2024 07:54:18 +0200 Subject: [PATCH 06/14] fix vctrs issue --- R/utils_compact.R | 9 ++++++++- tests/testthat/test-compact-list.R | 30 +++++++++++++++++++----------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/R/utils_compact.R b/R/utils_compact.R index 724b72672c..19f5562c8f 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -9,6 +9,13 @@ #' compact_list(c(1, NA, NA), remove_na = TRUE) #' @export compact_list <- function(x, remove_na = FALSE) { + # remove vctr-class attributes + if (is.data.frame(x)) { + x[] <- lapply(x, function(i) { + class(i) <- setdiff(class(i), c("haven_labelled", "vctrs_vctr")) + i + }) + } if (remove_na) { x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(i == "NULL", na.rm = TRUE)))] } else { @@ -30,5 +37,5 @@ compact_list <- function(x, remove_na = FALSE) { #' #' @export compact_character <- function(x) { - x[!sapply(x, function(i) nchar(i) == 0 || all(is.na(i)) || any(i == "NULL", na.rm = TRUE))] + x[!sapply(x, function(i) !nzchar(i, keepNA = TRUE) || all(is.na(i)) || any(i == "NULL", na.rm = TRUE))] } diff --git a/tests/testthat/test-compact-list.R b/tests/testthat/test-compact-list.R index a8a0096133..6867c6fed6 100644 --- a/tests/testthat/test-compact-list.R +++ b/tests/testthat/test-compact-list.R @@ -1,19 +1,27 @@ test_that("compact_list works as expected", { - expect_equal(compact_list(list(NULL, 1, c(NA, NA))), list(1, c(NA, NA))) - expect_equal(compact_list(c(1, NA, NA)), c(1, NA, NA)) - expect_equal(compact_list(list(NULL, 1, list(NULL, NULL))), list(1)) - expect_equal(compact_list(c(1, NA, NA), remove_na = TRUE), 1) - expect_equal(compact_list(c(1, 2, 3), remove_na = TRUE), c(1, 2, 3)) - expect_equal(compact_list(""), "") + expect_identical(compact_list(list(NULL, 1, c(NA, NA))), list(1, c(NA, NA))) + expect_identical(compact_list(c(1, NA, NA)), c(1, NA, NA)) + expect_identical(compact_list(list(NULL, 1, list(NULL, NULL))), list(1)) + expect_identical(compact_list(c(1, NA, NA), remove_na = TRUE), 1) + expect_identical(compact_list(c(1, 2, 3), remove_na = TRUE), c(1, 2, 3)) + expect_identical(compact_list(""), "") expect_null(compact_list(NULL)) - expect_equal(compact_list(logical(0)), logical(0)) + expect_identical(compact_list(logical(0)), logical(0)) }) test_that("compact_list, logical > 1", { x <- list(a = 1, b = c(1, 2), c = NA) - expect_equal(compact_list(x, remove_na = TRUE), list(a = 1, b = c(1, 2))) - expect_equal(compact_list(x, remove_na = FALSE), list(a = 1, b = c(1, 2), c = NA)) + expect_identical(compact_list(x, remove_na = TRUE), list(a = 1, b = c(1, 2))) + expect_identical(compact_list(x, remove_na = FALSE), list(a = 1, b = c(1, 2), c = NA)) x <- list(a = 1, b = c(NA, NA), c = NA) - expect_equal(compact_list(x, remove_na = TRUE), list(a = 1)) - expect_equal(compact_list(x, remove_na = FALSE), list(a = 1, b = c(NA, NA), c = NA)) + expect_identical(compact_list(x, remove_na = TRUE), list(a = 1)) + expect_identical(compact_list(x, remove_na = FALSE), list(a = 1, b = c(NA, NA), c = NA)) +}) + +test_that("compact_list, vctrs", { + data(mtcars) + class(mtcars$mpg) <- c("haven_labelled", "vctrs_vctr", "double") + attr(mtcars$mpg, "labels") <- c(`21` = 21) + out <- compact_list(mtcars) + expect_true(all(vapply(out, class, character(1)) == "numeric")) }) From 819c5788e5b5b86668f73f32c69edea03d5a310d Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Jun 2024 07:56:07 +0200 Subject: [PATCH 07/14] news --- NEWS.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/NEWS.md b/NEWS.md index 3f06b92be2..e7d47d4e06 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,6 +14,9 @@ * Fixed errors in CRAN checks. +* Fixed issues in `compact_list()` for objects that contained variables of + class `vctrs`. + # insight 0.19.11 ## General From 40c4fbce021ca275d823719e60f74717ff61f33d Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Jun 2024 07:57:21 +0200 Subject: [PATCH 08/14] typo --- NEWS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NEWS.md b/NEWS.md index e7d47d4e06..19bddd4bca 100644 --- a/NEWS.md +++ b/NEWS.md @@ -26,7 +26,7 @@ ## Bug fixes -* Fixed issue with `get_data()` for `coxme` models when `source`was set to +* Fixed issue with `get_data()` for `coxme` models when `source` was set to `"modelframe"`. # insight 0.19.10 From 300ef47fb67641cea264cd816f8135a182905b3b Mon Sep 17 00:00:00 2001 From: Daniel Date: Mon, 3 Jun 2024 14:55:02 +0200 Subject: [PATCH 09/14] submitted --- CRAN-SUBMISSION | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 4486e9c951..703fd41808 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.19.11 -Date: 2024-05-12 17:57:07 UTC -SHA: b850f730c05480293504a2b81217d9244de20f3e +Version: 0.20.0 +Date: 2024-06-03 12:54:55 UTC +SHA: 40c4fbce021ca275d823719e60f74717ff61f33d From f062fd776c19b0aaa2c0fa37144c960fff61f862 Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Sat, 1 Jun 2024 08:49:14 -0400 Subject: [PATCH 10/14] Fix compact_list() for labelled + other vctrs classes Closes https://github.com/easystats/performance/issues/727 --- R/utils_compact.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils_compact.R b/R/utils_compact.R index 19f5562c8f..56eec4549e 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -17,9 +17,9 @@ compact_list <- function(x, remove_na = FALSE) { }) } if (remove_na) { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(i == "NULL", na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(sapply(i, identical, y = "NULL"), na.rm = TRUE)))] } else { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(i == "NULL", na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(sapply(i, identical, y = "NULL"), na.rm = TRUE)))] } } From d70f73b804d81923101e21bdea644eea60ae7f6c Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Mon, 3 Jun 2024 10:01:21 -0700 Subject: [PATCH 11/14] Remove character "NULL" comparison to avoid vctrs errors --- R/utils_compact.R | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/R/utils_compact.R b/R/utils_compact.R index 56eec4549e..d5c64cb390 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -9,17 +9,10 @@ #' compact_list(c(1, NA, NA), remove_na = TRUE) #' @export compact_list <- function(x, remove_na = FALSE) { - # remove vctr-class attributes - if (is.data.frame(x)) { - x[] <- lapply(x, function(i) { - class(i) <- setdiff(class(i), c("haven_labelled", "vctrs_vctr")) - i - }) - } if (remove_na) { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(sapply(i, identical, y = "NULL"), na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(sapply(i, is.null), na.rm = TRUE)))] } else { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(sapply(i, identical, y = "NULL"), na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(sapply(i, is.null), na.rm = TRUE)))] } } From 64a1cce1b770275926cb65660af1892f622dcd07 Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Mon, 3 Jun 2024 12:23:09 -0700 Subject: [PATCH 12/14] Remove unnecessary test --- tests/testthat/test-compact-list.R | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/testthat/test-compact-list.R b/tests/testthat/test-compact-list.R index 6867c6fed6..aa92ac3747 100644 --- a/tests/testthat/test-compact-list.R +++ b/tests/testthat/test-compact-list.R @@ -17,11 +17,3 @@ test_that("compact_list, logical > 1", { expect_identical(compact_list(x, remove_na = TRUE), list(a = 1)) expect_identical(compact_list(x, remove_na = FALSE), list(a = 1, b = c(NA, NA), c = NA)) }) - -test_that("compact_list, vctrs", { - data(mtcars) - class(mtcars$mpg) <- c("haven_labelled", "vctrs_vctr", "double") - attr(mtcars$mpg, "labels") <- c(`21` = 21) - out <- compact_list(mtcars) - expect_true(all(vapply(out, class, character(1)) == "numeric")) -}) From dca73b7e23164f28b829d4763a40c8030f236e78 Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Mon, 3 Jun 2024 12:36:30 -0700 Subject: [PATCH 13/14] Preserve check against character "NULL" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use `is.character(i) || …` to head off vctrs-induced type mismatch --- R/utils_compact.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils_compact.R b/R/utils_compact.R index d5c64cb390..f2760d8a35 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -10,9 +10,9 @@ #' @export compact_list <- function(x, remove_na = FALSE) { if (remove_na) { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(sapply(i, is.null), na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(is.character(i) && i == "NULL", na.rm = TRUE)))] } else { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(sapply(i, is.null), na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(is.character(i) && i == "NULL", na.rm = TRUE)))] } } From c6d1394ec141186f3ad41b2a8995b98968112d4b Mon Sep 17 00:00:00 2001 From: "Brenton M. Wiernik" Date: Mon, 3 Jun 2024 14:26:58 -0700 Subject: [PATCH 14/14] Fix failing test --- R/utils_compact.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/utils_compact.R b/R/utils_compact.R index f2760d8a35..7baa4d8038 100644 --- a/R/utils_compact.R +++ b/R/utils_compact.R @@ -10,9 +10,9 @@ #' @export compact_list <- function(x, remove_na = FALSE) { if (remove_na) { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || any(is.character(i) && i == "NULL", na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || (length(i) == 1L && is.na(i)) || all(is.na(i)) || all(sapply(i, is.null)) || any(sapply(i, \(j) length(j) == 1 && is.character(j) && j == "NULL"), na.rm = TRUE)))] } else { - x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || any(is.character(i) && i == "NULL", na.rm = TRUE)))] + x[!sapply(x, function(i) !is_model(i) && !inherits(i, c("Formula", "gFormula")) && (length(i) == 0L || is.null(i) || all(sapply(i, is.null)) || any(sapply(i, \(j) length(j) == 1 && is.character(j) && j == "NULL"), na.rm = TRUE)))] } }