From 7ee2d31c2498609f613656e10a09ffb879496309 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 10 Sep 2023 20:57:00 +0200 Subject: [PATCH] CRAN submission 0.19.4 (#803) * CRAN submission 0.19.4 * fix issues with check_if_installed * add tests * version * cran comments * submitted [skip_ci] --- CRAN-SUBMISSION | 6 ++-- DESCRIPTION | 2 +- R/check_if_installed.R | 23 ++++++------ cran-comments.md | 4 +-- tests/testthat/test-check_if_installed.R | 46 ++++++++++++++++-------- 5 files changed, 48 insertions(+), 33 deletions(-) diff --git a/CRAN-SUBMISSION b/CRAN-SUBMISSION index 7d94196fa..031366b75 100644 --- a/CRAN-SUBMISSION +++ b/CRAN-SUBMISSION @@ -1,3 +1,3 @@ -Version: 0.19.3 -Date: 2023-06-27 17:03:53 UTC -SHA: 192c44fff3e72bc693d0b937e72028bf80513077 +Version: 0.19.4 +Date: 2023-09-10 18:00:28 UTC +SHA: a997ebabef3ad89306f1ba22d28e2189201087fa diff --git a/DESCRIPTION b/DESCRIPTION index 6c83abbec..678b9a529 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.3.5 +Version: 0.19.4 Authors@R: c(person(given = "Daniel", family = "Lüdecke", diff --git a/R/check_if_installed.R b/R/check_if_installed.R index db8d3875c..03192f456 100644 --- a/R/check_if_installed.R +++ b/R/check_if_installed.R @@ -68,24 +68,21 @@ check_if_installed <- function(package, what_you_can_do <- sprintf( "Please install %s by running `install.packages(%s)`.", if (length(package) > 1L) "them" else "it", - toString(sprintf("`%s`", package)) + toString(sprintf("\"%s\"", package)) ) } else if (!is.null(minimum_version)) { - current_versions <- unlist(lapply(package, function(x) { - as.character(utils::packageVersion(x)) - })) - - desired_versions <- unlist(lapply(minimum_version, function(x) { - if (is.na(x)) { - 0 + needs_update <- unlist(Map(function(p, m) { + if (is.na(m)) { + FALSE } else { - as.character(package_version(x)) + utils::packageVersion(p) < package_version(m) } - })) - - needs_update <- current_versions < desired_versions + }, package, minimum_version)) if (any(needs_update)) { + # set is_installed to FALSE for packages that fail minimum version check + is_installed[needs_update] <- FALSE + # only keep not-up-to-date packages package <- package[needs_update] minimum_version <- minimum_version[needs_update] @@ -103,7 +100,7 @@ check_if_installed <- function(package, what_you_can_do <- sprintf( "Please update %s by running `install.packages(%s)`.", if (length(package) > 1L) "them" else "it", - toString(sprintf("`%s`", package)) + toString(sprintf("\"%s\"", package)) ) } } diff --git a/cran-comments.md b/cran-comments.md index 3986ee2eb..853468126 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,8 +1,8 @@ -Maintainance release. +Maintainance release. Also required in preparation of the next version of the `performance` package, where an update was requested by the CRAN team. ## revdepcheck results -We checked 35 reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. +We checked all reverse dependencies, comparing R CMD check results across CRAN and dev versions of this package. * We saw 0 new problems * We failed to check 0 packages diff --git a/tests/testthat/test-check_if_installed.R b/tests/testthat/test-check_if_installed.R index b80e23be7..f0b5495e5 100644 --- a/tests/testthat/test-check_if_installed.R +++ b/tests/testthat/test-check_if_installed.R @@ -2,23 +2,16 @@ test_that("check_if_installed", { skip_if(interactive()) skip_if_not_installed("datawizard") skip_if_not_installed("rstanarm") + skip_if_not_installed("marginaleffects", minimum_version = "0.13.0") # mimic package name if cat were to walk on a keyboard expect_error(check_if_installed("xklfueofi8eur3rnfalfb")) - - expect_error(check_if_installed(c( - "datawizard", - minimum_version = "9.9.9" - ))) - - expect_no_error(check_if_installed(c( - "datawizard", "rstanarm" - ))) - - expect_no_error(check_if_installed(c( - "datawizard", "rstanarm" - ), minimum_version = c("0.8.0", "2.21.1"))) - + expect_error(check_if_installed("datawizard", minimum_version = "9.9.9")) + expect_no_error(check_if_installed(c("datawizard", "rstanarm"))) + expect_no_error(check_if_installed( + c("datawizard", "rstanarm"), + minimum_version = c("0.8.0", "2.21.1") + )) expect_no_error(check_if_installed(c( "datawizard", "rstanarm" ), minimum_version = c(NA, "2.21.1"))) @@ -26,4 +19,29 @@ test_that("check_if_installed", { expect_no_error(check_if_installed(c( "datawizard", "rstanarm" ), minimum_version = c("0.8.0", NA))) + + expect_no_error(check_if_installed("marginaleffects", minimum_version = "0.9.0")) + + out <- check_if_installed( + c("insight", "datawizard"), + minimum_version = c("999.30.0", NA), + prompt = FALSE, + quiet = TRUE + ) + expect_equal(out, c(FALSE, TRUE), ignore_attr = TRUE) + + out <- check_if_installed( + c("insight", "datawizard"), + prompt = FALSE, + quiet = TRUE + ) + expect_equal(out, c(TRUE, TRUE), ignore_attr = TRUE) + + out <- check_if_installed( + c("insight", "datawizard"), + minimum_version = c("0.1.0", "0.1.0"), + prompt = FALSE, + quiet = TRUE + ) + expect_equal(out, c(TRUE, TRUE), ignore_attr = TRUE) })