From a150a6ac09d5bf86f7ab680c0b2420a6d9098342 Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 12:50:40 -0500 Subject: [PATCH 1/9] usethis::use_standalone("r-lib/rlang", "type-check") --- DESCRIPTION | 1 + R/check_true_false.R | 43 +++ R/import-standalone-obj-type.R | 360 ++++++++++++++++++++ R/import-standalone-types-check.R | 538 ++++++++++++++++++++++++++++++ 4 files changed, 942 insertions(+) create mode 100644 R/check_true_false.R create mode 100644 R/import-standalone-obj-type.R create mode 100644 R/import-standalone-types-check.R diff --git a/DESCRIPTION b/DESCRIPTION index 8104515..9f84b5b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,6 +31,7 @@ Depends: Imports: phangorn, remotes, + rlang (>= 1.1.0), stringr, xml2 Suggests: diff --git a/R/check_true_false.R b/R/check_true_false.R new file mode 100644 index 0000000..3ece9dd --- /dev/null +++ b/R/check_true_false.R @@ -0,0 +1,43 @@ +# Created by modifying check_bool from import-standalone-type-check. +check_true <- function(x, + ..., + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + + if (!missing(x) && !isFALSE(x) &&.standalone_types_check_dot_call(ffi_standalone_is_bool_1.0.7, x, allow_na, allow_null)) { + return(invisible(NULL)) + } + + stop_input_type( + x, + c("`TRUE`"), + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} +# Adapted from standalone-types-check.R +check_false <- function(x, + ..., + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x) && !isTRUE(x) && .standalone_types_check_dot_call(ffi_standalone_is_bool_1.0.7, x, allow_na, allow_null)) { + return(invisible(NULL)) + } + + stop_input_type( + x, + c("`FALSE`"), + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} diff --git a/R/import-standalone-obj-type.R b/R/import-standalone-obj-type.R new file mode 100644 index 0000000..8e3c07d --- /dev/null +++ b/R/import-standalone-obj-type.R @@ -0,0 +1,360 @@ +# Standalone file: do not edit by hand +# Source: +# ---------------------------------------------------------------------- +# +# --- +# repo: r-lib/rlang +# file: standalone-obj-type.R +# last-updated: 2023-05-01 +# license: https://unlicense.org +# imports: rlang (>= 1.1.0) +# --- +# +# ## Changelog +# +# 2023-05-01: +# - `obj_type_friendly()` now only displays the first class of S3 objects. +# +# 2023-03-30: +# - `stop_input_type()` now handles `I()` input literally in `arg`. +# +# 2022-10-04: +# - `obj_type_friendly(value = TRUE)` now shows numeric scalars +# literally. +# - `stop_friendly_type()` now takes `show_value`, passed to +# `obj_type_friendly()` as the `value` argument. +# +# 2022-10-03: +# - Added `allow_na` and `allow_null` arguments. +# - `NULL` is now backticked. +# - Better friendly type for infinities and `NaN`. +# +# 2022-09-16: +# - Unprefixed usage of rlang functions with `rlang::` to +# avoid onLoad issues when called from rlang (#1482). +# +# 2022-08-11: +# - Prefixed usage of rlang functions with `rlang::`. +# +# 2022-06-22: +# - `friendly_type_of()` is now `obj_type_friendly()`. +# - Added `obj_type_oo()`. +# +# 2021-12-20: +# - Added support for scalar values and empty vectors. +# - Added `stop_input_type()` +# +# 2021-06-30: +# - Added support for missing arguments. +# +# 2021-04-19: +# - Added support for matrices and arrays (#141). +# - Added documentation. +# - Added changelog. +# +# nocov start + +#' Return English-friendly type +#' @param x Any R object. +#' @param value Whether to describe the value of `x`. Special values +#' like `NA` or `""` are always described. +#' @param length Whether to mention the length of vectors and lists. +#' @return A string describing the type. Starts with an indefinite +#' article, e.g. "an integer vector". +#' @noRd +obj_type_friendly <- function(x, value = TRUE) { + if (is_missing(x)) { + return("absent") + } + + if (is.object(x)) { + if (inherits(x, "quosure")) { + type <- "quosure" + } else { + type <- class(x)[[1L]] + } + return(sprintf("a <%s> object", type)) + } + + if (!is_vector(x)) { + return(.rlang_as_friendly_type(typeof(x))) + } + + n_dim <- length(dim(x)) + + if (!n_dim) { + if (!is_list(x) && length(x) == 1) { + if (is_na(x)) { + return(switch( + typeof(x), + logical = "`NA`", + integer = "an integer `NA`", + double = + if (is.nan(x)) { + "`NaN`" + } else { + "a numeric `NA`" + }, + complex = "a complex `NA`", + character = "a character `NA`", + .rlang_stop_unexpected_typeof(x) + )) + } + + show_infinites <- function(x) { + if (x > 0) { + "`Inf`" + } else { + "`-Inf`" + } + } + str_encode <- function(x, width = 30, ...) { + if (nchar(x) > width) { + x <- substr(x, 1, width - 3) + x <- paste0(x, "...") + } + encodeString(x, ...) + } + + if (value) { + if (is.numeric(x) && is.infinite(x)) { + return(show_infinites(x)) + } + + if (is.numeric(x) || is.complex(x)) { + number <- as.character(round(x, 2)) + what <- if (is.complex(x)) "the complex number" else "the number" + return(paste(what, number)) + } + + return(switch( + typeof(x), + logical = if (x) "`TRUE`" else "`FALSE`", + character = { + what <- if (nzchar(x)) "the string" else "the empty string" + paste(what, str_encode(x, quote = "\"")) + }, + raw = paste("the raw value", as.character(x)), + .rlang_stop_unexpected_typeof(x) + )) + } + + return(switch( + typeof(x), + logical = "a logical value", + integer = "an integer", + double = if (is.infinite(x)) show_infinites(x) else "a number", + complex = "a complex number", + character = if (nzchar(x)) "a string" else "\"\"", + raw = "a raw value", + .rlang_stop_unexpected_typeof(x) + )) + } + + if (length(x) == 0) { + return(switch( + typeof(x), + logical = "an empty logical vector", + integer = "an empty integer vector", + double = "an empty numeric vector", + complex = "an empty complex vector", + character = "an empty character vector", + raw = "an empty raw vector", + list = "an empty list", + .rlang_stop_unexpected_typeof(x) + )) + } + } + + vec_type_friendly(x) +} + +vec_type_friendly <- function(x, length = FALSE) { + if (!is_vector(x)) { + abort("`x` must be a vector.") + } + type <- typeof(x) + n_dim <- length(dim(x)) + + add_length <- function(type) { + if (length && !n_dim) { + paste0(type, sprintf(" of length %s", length(x))) + } else { + type + } + } + + if (type == "list") { + if (n_dim < 2) { + return(add_length("a list")) + } else if (is.data.frame(x)) { + return("a data frame") + } else if (n_dim == 2) { + return("a list matrix") + } else { + return("a list array") + } + } + + type <- switch( + type, + logical = "a logical %s", + integer = "an integer %s", + numeric = , + double = "a double %s", + complex = "a complex %s", + character = "a character %s", + raw = "a raw %s", + type = paste0("a ", type, " %s") + ) + + if (n_dim < 2) { + kind <- "vector" + } else if (n_dim == 2) { + kind <- "matrix" + } else { + kind <- "array" + } + out <- sprintf(type, kind) + + if (n_dim >= 2) { + out + } else { + add_length(out) + } +} + +.rlang_as_friendly_type <- function(type) { + switch( + type, + + list = "a list", + + NULL = "`NULL`", + environment = "an environment", + externalptr = "a pointer", + weakref = "a weak reference", + S4 = "an S4 object", + + name = , + symbol = "a symbol", + language = "a call", + pairlist = "a pairlist node", + expression = "an expression vector", + + char = "an internal string", + promise = "an internal promise", + ... = "an internal dots object", + any = "an internal `any` object", + bytecode = "an internal bytecode object", + + primitive = , + builtin = , + special = "a primitive function", + closure = "a function", + + type + ) +} + +.rlang_stop_unexpected_typeof <- function(x, call = caller_env()) { + abort( + sprintf("Unexpected type <%s>.", typeof(x)), + call = call + ) +} + +#' Return OO type +#' @param x Any R object. +#' @return One of `"bare"` (for non-OO objects), `"S3"`, `"S4"`, +#' `"R6"`, or `"R7"`. +#' @noRd +obj_type_oo <- function(x) { + if (!is.object(x)) { + return("bare") + } + + class <- inherits(x, c("R6", "R7_object"), which = TRUE) + + if (class[[1]]) { + "R6" + } else if (class[[2]]) { + "R7" + } else if (isS4(x)) { + "S4" + } else { + "S3" + } +} + +#' @param x The object type which does not conform to `what`. Its +#' `obj_type_friendly()` is taken and mentioned in the error message. +#' @param what The friendly expected type as a string. Can be a +#' character vector of expected types, in which case the error +#' message mentions all of them in an "or" enumeration. +#' @param show_value Passed to `value` argument of `obj_type_friendly()`. +#' @param ... Arguments passed to [abort()]. +#' @inheritParams args_error_context +#' @noRd +stop_input_type <- function(x, + what, + ..., + allow_na = FALSE, + allow_null = FALSE, + show_value = TRUE, + arg = caller_arg(x), + call = caller_env()) { + # From standalone-cli.R + cli <- env_get_list( + nms = c("format_arg", "format_code"), + last = topenv(), + default = function(x) sprintf("`%s`", x), + inherit = TRUE + ) + + if (allow_na) { + what <- c(what, cli$format_code("NA")) + } + if (allow_null) { + what <- c(what, cli$format_code("NULL")) + } + if (length(what)) { + what <- oxford_comma(what) + } + if (inherits(arg, "AsIs")) { + format_arg <- identity + } else { + format_arg <- cli$format_arg + } + + message <- sprintf( + "%s must be %s, not %s.", + format_arg(arg), + what, + obj_type_friendly(x, value = show_value) + ) + + abort(message, ..., call = call, arg = arg) +} + +oxford_comma <- function(chr, sep = ", ", final = "or") { + n <- length(chr) + + if (n < 2) { + return(chr) + } + + head <- chr[seq_len(n - 1)] + last <- chr[n] + + head <- paste(head, collapse = sep) + + # Write a or b. But a, b, or c. + if (n > 2) { + paste0(head, sep, final, " ", last) + } else { + paste0(head, " ", final, " ", last) + } +} + +# nocov end diff --git a/R/import-standalone-types-check.R b/R/import-standalone-types-check.R new file mode 100644 index 0000000..6782d69 --- /dev/null +++ b/R/import-standalone-types-check.R @@ -0,0 +1,538 @@ +# Standalone file: do not edit by hand +# Source: +# ---------------------------------------------------------------------- +# +# --- +# repo: r-lib/rlang +# file: standalone-types-check.R +# last-updated: 2023-03-13 +# license: https://unlicense.org +# dependencies: standalone-obj-type.R +# imports: rlang (>= 1.1.0) +# --- +# +# ## Changelog +# +# 2023-03-13: +# - Improved error messages of number checkers (@teunbrand) +# - Added `allow_infinite` argument to `check_number_whole()` (@mgirlich). +# - Added `check_data_frame()` (@mgirlich). +# +# 2023-03-07: +# - Added dependency on rlang (>= 1.1.0). +# +# 2023-02-15: +# - Added `check_logical()`. +# +# - `check_bool()`, `check_number_whole()`, and +# `check_number_decimal()` are now implemented in C. +# +# - For efficiency, `check_number_whole()` and +# `check_number_decimal()` now take a `NULL` default for `min` and +# `max`. This makes it possible to bypass unnecessary type-checking +# and comparisons in the default case of no bounds checks. +# +# 2022-10-07: +# - `check_number_whole()` and `_decimal()` no longer treat +# non-numeric types such as factors or dates as numbers. Numeric +# types are detected with `is.numeric()`. +# +# 2022-10-04: +# - Added `check_name()` that forbids the empty string. +# `check_string()` allows the empty string by default. +# +# 2022-09-28: +# - Removed `what` arguments. +# - Added `allow_na` and `allow_null` arguments. +# - Added `allow_decimal` and `allow_infinite` arguments. +# - Improved errors with absent arguments. +# +# +# 2022-09-16: +# - Unprefixed usage of rlang functions with `rlang::` to +# avoid onLoad issues when called from rlang (#1482). +# +# 2022-08-11: +# - Added changelog. +# +# nocov start + +# Scalars ----------------------------------------------------------------- + +.standalone_types_check_dot_call <- .Call + +check_bool <- function(x, + ..., + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x) && .standalone_types_check_dot_call(ffi_standalone_is_bool_1.0.7, x, allow_na, allow_null)) { + return(invisible(NULL)) + } + + stop_input_type( + x, + c("`TRUE`", "`FALSE`"), + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_string <- function(x, + ..., + allow_empty = TRUE, + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + is_string <- .rlang_check_is_string( + x, + allow_empty = allow_empty, + allow_na = allow_na, + allow_null = allow_null + ) + if (is_string) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a single string", + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +.rlang_check_is_string <- function(x, + allow_empty, + allow_na, + allow_null) { + if (is_string(x)) { + if (allow_empty || !is_string(x, "")) { + return(TRUE) + } + } + + if (allow_null && is_null(x)) { + return(TRUE) + } + + if (allow_na && (identical(x, NA) || identical(x, na_chr))) { + return(TRUE) + } + + FALSE +} + +check_name <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + is_string <- .rlang_check_is_string( + x, + allow_empty = FALSE, + allow_na = FALSE, + allow_null = allow_null + ) + if (is_string) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a valid name", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +IS_NUMBER_true <- 0 +IS_NUMBER_false <- 1 +IS_NUMBER_oob <- 2 + +check_number_decimal <- function(x, + ..., + min = NULL, + max = NULL, + allow_infinite = TRUE, + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (missing(x)) { + exit_code <- IS_NUMBER_false + } else if (0 == (exit_code <- .standalone_types_check_dot_call( + ffi_standalone_check_number_1.0.7, + x, + allow_decimal = TRUE, + min, + max, + allow_infinite, + allow_na, + allow_null + ))) { + return(invisible(NULL)) + } + + .stop_not_number( + x, + ..., + exit_code = exit_code, + allow_decimal = TRUE, + min = min, + max = max, + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_number_whole <- function(x, + ..., + min = NULL, + max = NULL, + allow_infinite = FALSE, + allow_na = FALSE, + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (missing(x)) { + exit_code <- IS_NUMBER_false + } else if (0 == (exit_code <- .standalone_types_check_dot_call( + ffi_standalone_check_number_1.0.7, + x, + allow_decimal = FALSE, + min, + max, + allow_infinite, + allow_na, + allow_null + ))) { + return(invisible(NULL)) + } + + .stop_not_number( + x, + ..., + exit_code = exit_code, + allow_decimal = FALSE, + min = min, + max = max, + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +.stop_not_number <- function(x, + ..., + exit_code, + allow_decimal, + min, + max, + allow_na, + allow_null, + arg, + call) { + if (allow_decimal) { + what <- "a number" + } else { + what <- "a whole number" + } + + if (exit_code == IS_NUMBER_oob) { + min <- min %||% -Inf + max <- max %||% Inf + + if (min > -Inf && max < Inf) { + what <- sprintf("%s between %s and %s", what, min, max) + } else if (x < min) { + what <- sprintf("%s larger than or equal to %s", what, min) + } else if (x > max) { + what <- sprintf("%s smaller than or equal to %s", what, max) + } else { + abort("Unexpected state in OOB check", .internal = TRUE) + } + } + + stop_input_type( + x, + what, + ..., + allow_na = allow_na, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_symbol <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_symbol(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a symbol", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_arg <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_symbol(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "an argument name", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_call <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_call(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a defused call", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_environment <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_environment(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "an environment", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_function <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_function(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a function", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_closure <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_closure(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "an R function", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_formula <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_formula(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a formula", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + + +# Vectors ----------------------------------------------------------------- + +check_character <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_character(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a character vector", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_logical <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is_logical(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a logical vector", + ..., + allow_na = FALSE, + allow_null = allow_null, + arg = arg, + call = call + ) +} + +check_data_frame <- function(x, + ..., + allow_null = FALSE, + arg = caller_arg(x), + call = caller_env()) { + if (!missing(x)) { + if (is.data.frame(x)) { + return(invisible(NULL)) + } + if (allow_null && is_null(x)) { + return(invisible(NULL)) + } + } + + stop_input_type( + x, + "a data frame", + ..., + allow_null = allow_null, + arg = arg, + call = call + ) +} + +# nocov end From b3425f769bd8e80a7a59a4c8922f734705d8d7c2 Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:33:16 -0500 Subject: [PATCH 2/9] Import rlang --- NAMESPACE | 1 + NEWS.md | 3 ++- R/babette-package.R | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 72d8e81..038c1b5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,7 @@ export(parse_beast2_output_to_ns) export(plot_densitree) export(prepare_file_creation) export(update_babette) +import(rlang) importFrom(beastier,add_quotes_if_has_spaces) importFrom(beastier,are_beast2_input_lines) importFrom(beastier,are_beast2_input_lines_deep) diff --git a/NEWS.md b/NEWS.md index 4cdd2d9..f5a8824 100644 --- a/NEWS.md +++ b/NEWS.md @@ -14,7 +14,8 @@ Newest versions at top. ### BUG FIXES - * None + * Removed unused dependencies, and testthat dependency outside tests. + * Import rlang for checking conditions. ### DEPRECATED AND DEFUNCT diff --git a/R/babette-package.R b/R/babette-package.R index 4d9f279..4e26a51 100644 --- a/R/babette-package.R +++ b/R/babette-package.R @@ -602,5 +602,6 @@ "_PACKAGE" ## usethis namespace: start +#' @import rlang ## usethis namespace: end NULL From 14af54448b1c78739b76eac3a85d39832d25cf59 Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:34:38 -0500 Subject: [PATCH 3/9] Remove testthat from `R/` --- R/bbt_continue.R | 23 +++++++++++++++++------ R/bbt_run_from_model.R | 17 ++++++++++++----- R/bbt_self_test.R | 5 ++++- R/parse_beast2_output_to_ns.R | 4 ++-- R/prepare_file_creation.R | 4 +++- 5 files changed, 38 insertions(+), 15 deletions(-) diff --git a/R/bbt_continue.R b/R/bbt_continue.R index f7147dc..3c95935 100644 --- a/R/bbt_continue.R +++ b/R/bbt_continue.R @@ -114,7 +114,7 @@ bbt_continue <- function( beast2_options$input_filename, "beast2_options$input_filename" ) - testthat::expect_true( + check_true( beastier::is_beast2_input_file(beast2_options$input_filename) ) beautier::check_file_exists( @@ -132,7 +132,12 @@ bbt_continue <- function( beautier::get_alignment_id(fasta_filename), ".log" ) } - testthat::expect_true(!is.na(inference_model$mcmc$tracelog$filename)) + + if (is.na(inference_model$mcmc$tracelog$filename)) { + stop( + "Expected inference_model$mcmc$tracelog$filename not to be missing." + ) + } if (!file.exists(normalizePath(inference_model$mcmc$tracelog$filename))) { stop( "'mcmc$tracelog$filename' not found. \n", @@ -152,7 +157,7 @@ bbt_continue <- function( pattern = "\\$\\(tree\\)", replacement = beautier::get_alignment_id(fasta_filename) ) - testthat::expect_true(file.exists(inference_model$mcmc$treelog$filename) && + check_true(file.exists(inference_model$mcmc$treelog$filename) && length( paste0( "'mcmc$treelog$filename' not found. \n", @@ -162,7 +167,7 @@ bbt_continue <- function( ) ) ) - testthat::expect_true(file.exists(beast2_options$output_state_filename) && + check_true(file.exists(beast2_options$output_state_filename) && length( paste0( "beast2_output_state_filename not found. \n", @@ -189,9 +194,15 @@ bbt_continue <- function( n_trees_in_file <- tracerer::count_trees_in_file( inference_model$mcmc$treelog$filename ) - testthat::expect_true(inherits(out[[1]], "multiPhylo")) + + if (!inherits(out[[1]], "multiPhylo")) { + stop("Expected out to be a multiPhylo object.") + } n_trees_in_output <- length(out[[1]]) - testthat::expect_equal(n_trees_in_file, n_trees_in_output) + + if (n_trees_in_file != n_trees_in_output) { + stop("Expected n_trees_in_files to be equal to n_trees_in_output") + } # Process the package specific output, # for example, add an 'ns' atributed for Nested Sampling diff --git a/R/bbt_run_from_model.R b/R/bbt_run_from_model.R index 5d3a2da..97b2787 100644 --- a/R/bbt_run_from_model.R +++ b/R/bbt_run_from_model.R @@ -127,8 +127,10 @@ bbt_run_from_model <- function( beautier::get_alignment_id(fasta_filename), ".log" ) } - testthat::expect_true(!is.na(inference_model$mcmc$tracelog$filename)) - testthat::expect_true( + if (is.na(inference_model$mcmc$tracelog$filename)) { + stop("inference_model$mcmc$tracelog$filename should not be missing.") + } + check_true( file.exists(normalizePath(inference_model$mcmc$tracelog$filename)) && length( paste0( @@ -156,7 +158,8 @@ bbt_run_from_model <- function( ) ) ) - testthat::expect_true(file.exists(beast2_options$output_state_filename) && + # Should this be if (!file.exists) stop(paste0(...))? + check_true(file.exists(beast2_options$output_state_filename) && length( paste0( "beast2_output_state_filename not found. \n", @@ -183,9 +186,13 @@ bbt_run_from_model <- function( n_trees_in_file <- tracerer::count_trees_in_file( inference_model$mcmc$treelog$filename ) - testthat::expect_true(inherits(out[[1]], "multiPhylo")) + if (!inherits(out[[1]], "multiPhylo")) { + stop("out[[1]] should be multiPhylo.") + } n_trees_in_output <- length(out[[1]]) - testthat::expect_equal(n_trees_in_file, n_trees_in_output) + if (n_trees_in_file != n_trees_in_output) { + stop("n_trees_in_file should be equal to n_trees_in_output.") + } # Process the package specific output, # for example, add an 'ns' atributed for Nested Sampling diff --git a/R/bbt_self_test.R b/R/bbt_self_test.R index 2f4b3e9..2176fee 100644 --- a/R/bbt_self_test.R +++ b/R/bbt_self_test.R @@ -15,7 +15,10 @@ bbt_self_test <- function( beast2_options = beastier::create_beast2_options() ) { - testthat::expect_true(beastier::is_beast2_installed()) + + if (!beastier::is_beast2_installed()) { + stop("Beast2 must be installed for bbt_self_test.") + } inference_model <- beautier::create_test_inference_model() babette::bbt_run_from_model( fasta_filename = beautier::get_fasta_filename(), diff --git a/R/parse_beast2_output_to_ns.R b/R/parse_beast2_output_to_ns.R index 108f4d1..aa5c101 100644 --- a/R/parse_beast2_output_to_ns.R +++ b/R/parse_beast2_output_to_ns.R @@ -31,7 +31,7 @@ parse_beast2_output_to_ns <- function( # Extract the line x <- stringr::str_extract(output, "Marginal likelihood: -?[0-9\\.]+\\(.*\\)$") x <- x[!is.na(x)] - testthat::expect_equal(length(x), 1) + check_string(x) # Get the marginal log likelihood ns$marg_log_lik <- as.numeric( @@ -56,7 +56,7 @@ parse_beast2_output_to_ns <- function( x <- stringr::str_extract(output, "Max ESS: [0-9\\.]+$") x <- x[!is.na(x)] # There are two ESSes, just pick the first - testthat::expect_true(length(x) >= 2) + check_number_whole(length(x), min = 2) x <- x[1] # Get the marginal log likelihood diff --git a/R/prepare_file_creation.R b/R/prepare_file_creation.R index 4170cf4..f888df6 100644 --- a/R/prepare_file_creation.R +++ b/R/prepare_file_creation.R @@ -55,7 +55,9 @@ prepare_file_creation <- function( ) } file.remove(filename) - testthat::expect_true(!file.exists(filename)) + if (file.exists(filename)) { + stop("filename should not exist, as it has been deleted.") + } } invisible(inference_model) } From b242909f8ac86fe6dde4bf7af4bfaee178442efe Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:35:02 -0500 Subject: [PATCH 4/9] Remove remotes import as update_babette is deprecated. --- R/update_babette.R | 2 +- man/update_babette.Rd | 20 ++++++-------------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/R/update_babette.R b/R/update_babette.R index dfef581..ae021b1 100644 --- a/R/update_babette.R +++ b/R/update_babette.R @@ -5,7 +5,7 @@ #' #' See \url{https://github.com/richelbilderbeek/babetteinstall} #' how to do this. -#' @inheritParams remotes::install_github +#' @param upgrade Deprecated. #' @author Giovanni Laudanno, Richèl J.C. Bilderbeek #' @export update_babette <- function(upgrade = "default") { diff --git a/man/update_babette.Rd b/man/update_babette.Rd index fa939c8..ee0c497 100644 --- a/man/update_babette.Rd +++ b/man/update_babette.Rd @@ -2,28 +2,20 @@ % Please edit documentation in R/update_babette.R \name{update_babette} \alias{update_babette} -\title{Update all babette dependencies, by installing their -latest versions} +\title{Deprecated function.} \usage{ update_babette(upgrade = "default") } \arguments{ -\item{upgrade}{Should package dependencies be upgraded? One of "default", "ask", "always", or "never". "default" -respects the value of the \code{R_REMOTES_UPGRADE} environment variable if set, -and falls back to "ask" if unset. "ask" prompts the user for which out of -date packages to upgrade. For non-interactive sessions "ask" is equivalent -to "always". \code{TRUE} and \code{FALSE} are also accepted and correspond to -"always" and "never" respectively.} +\item{upgrade}{Deprecated.} } \description{ Update all babette dependencies, by installing their -latest versions +latest versions. } -\examples{ -\dontrun{ - # Updates the babette dependencies without asking -} -beastier::remove_beaustier_folders() +\details{ +See \url{https://github.com/richelbilderbeek/babetteinstall} +how to do this. } \author{ Giovanni Laudanno, Richèl J.C. Bilderbeek From a7f812867d50d6694d5dfd95efd8673284cbc60c Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:35:24 -0500 Subject: [PATCH 5/9] Use less rappdirs and more testthat skips. --- tests/testthat/test-bbt_run.R | 40 ++++++++++----------- tests/testthat/test-bbt_run_from_model.R | 6 ++-- tests/testthat/test-bbt_run_ns.R | 13 +++---- tests/testthat/test-nested_sampling.R | 8 ++--- tests/testthat/test-plot_densitree.R | 2 +- tests/testthat/test-prepare_file_creation.R | 2 +- 6 files changed, 32 insertions(+), 39 deletions(-) diff --git a/tests/testthat/test-bbt_run.R b/tests/testthat/test-bbt_run.R index a405fe5..2119a58 100644 --- a/tests/testthat/test-bbt_run.R +++ b/tests/testthat/test-bbt_run.R @@ -1,6 +1,6 @@ test_that("output is well-formed", { - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") mcmc <- create_test_mcmc() inference_model <- beautier::create_inference_model( @@ -105,12 +105,9 @@ test_that("use, one alignment, verbose, no cleanup", { test_that("same RNG seed gives same results", { - if (!beastier::is_beast2_installed()) return() - - if (rappdirs::app_dir()$os == "mac") { - return() - # RNG seed is unreliable under macOS - } + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") + skip_on_os("mac") + # RNG seed is unreliable under macOS rng_seed <- 42 inference_model_1 <- create_test_inference_model() @@ -233,7 +230,7 @@ test_that("Run all defaults", { test_that("Run GTR", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( site_model = create_gtr_site_model() @@ -260,7 +257,7 @@ test_that("Run GTR", { test_that("Run HKY", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( site_model = create_hky_site_model() @@ -287,7 +284,7 @@ test_that("Run HKY", { test_that("Run JC69", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( site_model = create_jc69_site_model() @@ -314,7 +311,7 @@ test_that("Run JC69", { test_that("Run TN93", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( site_model = create_tn93_site_model() @@ -400,7 +397,7 @@ test_that("Run strict clock", { test_that("Run BD tree prior", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( tree_prior = create_bd_tree_prior() @@ -426,7 +423,7 @@ test_that("Run BD tree prior", { test_that("Run CBS tree prior", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_inference_model( tree_prior = create_cbs_tree_prior( @@ -478,7 +475,7 @@ test_that("Run CBS tree prior with too few taxa must give clear error", { test_that("Run CCP tree prior", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( tree_prior = create_ccp_tree_prior() ) @@ -499,7 +496,7 @@ test_that("Run CCP tree prior", { test_that("Run CCP tree prior with tip dating", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- beautier::create_test_inference_model( tree_prior = create_ccp_tree_prior(), tipdates_filename = beautier::get_beautier_path( @@ -553,7 +550,7 @@ test_that("Run CEP tree prior", { ################################################################################ test_that("Run Yule tree prior", { if (!beautier::is_on_ci()) return() - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") inference_model <- create_inference_model( tree_prior = create_yule_tree_prior(), mcmc = create_test_mcmc(chain_length = 2000) @@ -578,7 +575,7 @@ test_that("Run Yule tree prior", { # MRCA priors ################################################################################ test_that("Run MRCA, no distr", { - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") fasta_filename <- get_fasta_filename() lines <- beautier::create_beast2_input( @@ -595,7 +592,7 @@ test_that("Run MRCA, no distr", { test_that("Run MRCA, MRCA distr", { - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") fasta_filename <- get_fasta_filename() lines <- beautier::create_beast2_input( @@ -636,8 +633,7 @@ test_that("Run MRCA, no distr, subset of taxa", { test_that("RLN and non-monophyletic MRCA with distribution, Issue 29, #29", { skip("#29") - if (!beastier::is_beast2_installed()) return() - + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") # Thanks to Raphael Scherrer for sharing this bug @@ -666,7 +662,7 @@ test_that("RLN and non-monophyletic MRCA with distribution, Issue 29, #29", { test_that("RLN and monophyletic MRCA with distribution, Issue 29, #29", { skip("#29") - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") # Thanks to Jana Riederer for sharing this bug fasta_filename <- get_fasta_filename() @@ -723,7 +719,7 @@ test_that("use, one alignment, plot with nLTT", { test_that("with tip dating", { - if (!beastier::is_beast2_installed()) return() + skip_if_not(beastier::is_beast2_installed(), message = "beast2 not installed") fasta_filename <- beautier::get_beautier_path("G_VII_pre2003_msa.fas") tipdates_filename <- beautier::get_beautier_path("G_VII_pre2003_dates_4.txt") diff --git a/tests/testthat/test-bbt_run_from_model.R b/tests/testthat/test-bbt_run_from_model.R index 4f4b56a..c8a49d3 100644 --- a/tests/testthat/test-bbt_run_from_model.R +++ b/tests/testthat/test-bbt_run_from_model.R @@ -51,7 +51,7 @@ test_that("minimal use with BEAUti shorthand", { test_that("use, nested sampling", { if (!beastier::is_beast2_installed()) return() - if (rappdirs::app_dir()$os == "win") return() + skip_on_os("windows") if (!mauricer::is_beast2_ns_pkg_installed()) return() beastier::remove_beaustier_folders() @@ -200,9 +200,9 @@ test_that("Run CBS tree prior with too few taxa must give clear error", { }) test_that("use, nested sampling, in custom folder", { - if (rappdirs::app_dir()$os == "win") return() + skip_on_os("windows") if (!beautier::is_on_ci()) return() - if (!curl::has_internet()) return() + skip_if_offline() beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders() diff --git a/tests/testthat/test-bbt_run_ns.R b/tests/testthat/test-bbt_run_ns.R index 64e3dd3..53ee23e 100644 --- a/tests/testthat/test-bbt_run_ns.R +++ b/tests/testthat/test-bbt_run_ns.R @@ -1,6 +1,6 @@ test_that("use, bin (Linux only)", { if (!beastier::is_beast2_installed()) return() - if (rappdirs::app_dir()$os == "win") return() + skip_on_os("windows") if (!mauricer::is_beast2_ns_pkg_installed()) return() beastier::remove_beaustier_folders() @@ -18,16 +18,13 @@ test_that("use, bin (Linux only)", { beast2_options = beast2_options ) - expect_true("estimates" %in% names(out)) - expect_true("anthus_aco_sub_trees" %in% names(out)) - expect_true("operators" %in% names(out)) - expect_true("output" %in% names(out)) + expect_contains(names(out), c("estimates", "anthus_aco_sub_trees", "operators", "output")) if (1 == 2) { # This assumption is false: a Nested Sampling run runs until # convergence - testthat::expect_true(inherits(out$anthus_aco_trees[[1]], "phylo")) - testthat::expect_equal(length(out$anthus_aco_trees), 2) + expect_s3_class(out$anthus_aco_trees[[1]], "phylo") + expect_length(out$anthus_aco_trees, 2) } expect_true("Sample" %in% names(out$estimates)) @@ -64,7 +61,7 @@ test_that("use, bin (Linux only)", { test_that("be verbose (yet muted)", { if (!beastier::is_beast2_installed()) return() - if (rappdirs::app_dir()$os != "win") return() + skip_on_os(c("mac", "linux")) # only run on Windows. if (!mauricer::is_beast2_ns_pkg_installed()) return() beastier::remove_beaustier_folders() diff --git a/tests/testthat/test-nested_sampling.R b/tests/testthat/test-nested_sampling.R index 7fb0663..89de8e5 100644 --- a/tests/testthat/test-nested_sampling.R +++ b/tests/testthat/test-nested_sampling.R @@ -1,7 +1,7 @@ test_that("use, bin, Linux", { if (!is_beast2_installed()) return() if (!mauricer::is_beast2_ns_pkg_installed()) return() - if (rappdirs::app_dir()$os != "unix") return() + skip_on_os("windows") beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders() @@ -22,7 +22,7 @@ test_that("use, bin, Linux", { test_that("use, jar, Linux, works", { if (!is_beast2_installed()) return() if (!mauricer::is_beast2_ns_pkg_installed()) return() - if (rappdirs::app_dir()$os != "unix") return() + skip_on_os("windows") beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders() @@ -51,7 +51,7 @@ test_that("use, bin, Win, fails", { if (!is_beast2_installed()) return() if (!mauricer::is_beast2_ns_pkg_installed()) return() - if (rappdirs::app_dir()$os != "win") return() + skip_on_os(c("solaris", "linux", "mac")) input_filename <- get_babette_path("nested_sampling.xml") @@ -71,7 +71,7 @@ test_that("use, bin, Win, fails", { test_that("use, jar, Win, fails", { if (!is_beast2_installed()) return() if (!mauricer::is_beast2_ns_pkg_installed()) return() - if (rappdirs::app_dir()$os != "win") return() + skip_on_os(c("mac", "linux", "solaris")) beastier::remove_beaustier_folders() beastier::check_empty_beaustier_folders() diff --git a/tests/testthat/test-plot_densitree.R b/tests/testthat/test-plot_densitree.R index 30570c9..adb3b21 100644 --- a/tests/testthat/test-plot_densitree.R +++ b/tests/testthat/test-plot_densitree.R @@ -48,7 +48,7 @@ test_that("minimal use", { test_that("abuse", { - testthat::expect_error( + expect_error( plot_densitree("nonsense"), "'phylos' must be of class 'multiPhylo'" ) diff --git a/tests/testthat/test-prepare_file_creation.R b/tests/testthat/test-prepare_file_creation.R index 9cbd394..85baf68 100644 --- a/tests/testthat/test-prepare_file_creation.R +++ b/tests/testthat/test-prepare_file_creation.R @@ -81,7 +81,7 @@ test_that("output_state_filename in sub-sub-sub-folder", { }) test_that("state file in root folder", { - if (rappdirs::app_dir()$os == "win") return() + skip_on_os("windows") filename <- "/not_in_root_please.xml.state" From 9ba74a79b275962e3f61c24352ed13b0b099bbbc Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:35:58 -0500 Subject: [PATCH 6/9] Remove testthat from vignettes. --- scripts/issue_101.r | 4 +++- vignettes/nested_sampling.Rmd | 26 +++++++++++++------------- vignettes/step_by_step.Rmd | 4 +++- vignettes/tutorial.Rmd | 3 +-- 4 files changed, 20 insertions(+), 17 deletions(-) diff --git a/scripts/issue_101.r b/scripts/issue_101.r index 5135dd5..301ffef 100644 --- a/scripts/issue_101.r +++ b/scripts/issue_101.r @@ -1,5 +1,7 @@ # Issue #101 -testthat::expect_true(beastier::is_beast2_installed()) +if (!beastier::is_beast2_installed()) { + stop("Beast2 must be installed.") +} zip_filename_url <- "https://github.com/ropensci/babette/files/7802540/airCommunitiesMM_1.zip" zip_filename <- tempfile(fileext = ".zip") diff --git a/vignettes/nested_sampling.Rmd b/vignettes/nested_sampling.Rmd index 4101965..e353525 100644 --- a/vignettes/nested_sampling.Rmd +++ b/vignettes/nested_sampling.Rmd @@ -33,7 +33,6 @@ as described in [1] ```{r} library(babette) -library(testthat) ``` `babette` needs to have 'BEAST2' installed to work. @@ -74,18 +73,19 @@ interpret_bayes_factor <- function(bayes_factor) { "decisive for JC69" } } -expect_equal(interpret_bayes_factor(1 / 123.0), "decisive for GTR") -expect_equal(interpret_bayes_factor(1 / 85.0), "very strong for GTR") -expect_equal(interpret_bayes_factor(1 / 12.5), "strong for GTR") -expect_equal(interpret_bayes_factor(1 / 8.5), "substantial for GTR") -expect_equal(interpret_bayes_factor(1 / 1.5), "barely worth mentioning for GTR") -expect_equal(interpret_bayes_factor(0.99), "barely worth mentioning for GTR") -expect_equal(interpret_bayes_factor(1.01), "barely worth mentioning for JC69") -expect_equal(interpret_bayes_factor(1.5), "barely worth mentioning for JC69") -expect_equal(interpret_bayes_factor(8.5), "substantial for JC69") -expect_equal(interpret_bayes_factor(12.5), "strong for JC69") -expect_equal(interpret_bayes_factor(85.0), "very strong for JC69") -expect_equal(interpret_bayes_factor(123.0), "decisive for JC69") +# Should all be TRUE +interpret_bayes_factor(1 / 123.0) == "decisive for GTR" +interpret_bayes_factor(1 / 85.0) == "very strong for GTR" +interpret_bayes_factor(1 / 12.5) == "strong for GTR" +interpret_bayes_factor(1 / 8.5) == "substantial for GTR" +interpret_bayes_factor(1 / 1.5) == "barely worth mentioning for GTR" +interpret_bayes_factor(0.99) == "barely worth mentioning for GTR" +interpret_bayes_factor(1.01) == "barely worth mentioning for JC69" +interpret_bayes_factor(1.5) == "barely worth mentioning for JC69" +interpret_bayes_factor(8.5) == "substantial for JC69" +interpret_bayes_factor(12.5) == "strong for JC69" +interpret_bayes_factor(85.0) == "very strong for JC69" +interpret_bayes_factor(123.0) == "decisive for JC69" ``` ## Experiment diff --git a/vignettes/step_by_step.Rmd b/vignettes/step_by_step.Rmd index 8d7f730..6e704af 100644 --- a/vignettes/step_by_step.Rmd +++ b/vignettes/step_by_step.Rmd @@ -99,7 +99,9 @@ if (is_beast2_installed()) { run_beast2_from_options( beast2_options = beast2_options ) - testthat::expect_true(file.exists(beast2_options$output_state_filename)) + if (!file.exists(beast2_options$output_state_filename)) { + stop("the filename should have been created.") + } } ``` diff --git a/vignettes/tutorial.Rmd b/vignettes/tutorial.Rmd index d8838ef..637eac9 100644 --- a/vignettes/tutorial.Rmd +++ b/vignettes/tutorial.Rmd @@ -66,8 +66,7 @@ so obtaining a path to a FASTA file is easy: ```{r} fasta_filename <- get_babette_path("anthus_aco_sub.fas") -library(testthat) -expect_true(file.exists(fasta_filename)) +file.exists(fasta_filename) ``` With `fasta_filename` available, we have the minimal From 3dc81f01ca0e5bde4ca9ba02f891a77df561165d Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:36:28 -0500 Subject: [PATCH 7/9] Update DESCRIPTIOn + actions --- .github/workflows/R-CMD-check.yaml | 10 +++++----- DESCRIPTION | 9 ++------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index fd5f69d..2c52e15 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -68,23 +68,23 @@ jobs: shell: Rscript {0} - name: Make sure that no files are created in the beautier .cache folder - run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "beautier")))) + run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "beautier")), 0) shell: Rscript {0} - name: Make sure that no files are created in the tracerer .cache folder - run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "tracerer")))) + run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "tracerer")), 0) shell: Rscript {0} - name: Make sure that no files are created in the beastier .cache folder - run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "beastier")))) + run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "beastier")), 0) shell: Rscript {0} - name: Make sure that no files are created in the mauricer .cache folder - run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "mauricer")))) + run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "mauricer")), 0) shell: Rscript {0} - name: Make sure that no files are created in the .cache folder - run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "babette")))) + run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "babette")), 0) shell: Rscript {0} - name: Test coverage diff --git a/DESCRIPTION b/DESCRIPTION index 9f84b5b..bd6bc77 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,6 @@ Authors@R: c( person("David", "Winter", role = "rev", comment = "David reviewed the package for rOpenSci, see https://github.com/richelbilderbeek/onboarding/issues/209"), person("Jason", "Griffiths", role = "ctb", comment = c(ORCID = "0000-0002-1667-8233")), person("Giovanni", "Laudanno", email = "glaudanno@gmail.com", role = "ctb")) -Maintainer: Richèl J.C. Bilderbeek Description: 'BEAST2' () is a widely used Bayesian phylogenetic tool, that uses DNA/RNA/protein data and many model priors to create a posterior of jointly estimated @@ -19,8 +18,8 @@ Description: 'BEAST2' () is a widely used License: GPL-3 RoxygenNote: 7.2.3 VignetteBuilder: knitr -URL: https://docs.ropensci.org/babette/ (website) - https://github.com/ropensci/babette/ +URL: https://docs.ropensci.org/babette/ (website), + https://github.com/ropensci/babette BugReports: https://github.com/ropensci/babette/issues Depends: beautier (>= 2.6.11), @@ -30,18 +29,14 @@ Depends: tracerer Imports: phangorn, - remotes, rlang (>= 1.1.0), stringr, xml2 Suggests: ape, - curl, ggplot2, - hunspell, knitr, lintr, - markdown, nLTT, rappdirs, rmarkdown, From 99ed393768a78ccb5d9eddd74bee2213d68a5a6b Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 13:44:45 -0500 Subject: [PATCH 8/9] Update links with `urlchecker::url_update()` --- NEWS.md | 2 +- README.md | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/NEWS.md b/NEWS.md index f5a8824..86cc1a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -360,7 +360,7 @@ create_lambda_param(value = 1.2, estimate = TRUE) ### MINOR IMPROVEMENTS - * Follow all [rOpenSci packaging guidelines](https://github.com/ropensci/onboarding/blob/master/packaging_guide.md) + * Follow all [rOpenSci packaging guidelines](https://github.com/ropensci/software-review/blob/master/packaging_guide.md) ### BUG FIXES diff --git a/README.md b/README.md index f96e06c..1117711 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@ # babette -[![Peer Review Status](https://badges.ropensci.org/209_status.svg)](https://github.com/ropensci/onboarding/issues/209) +[![Peer Review Status](https://badges.ropensci.org/209_status.svg)](https://github.com/ropensci/software-review/issues/209) [![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/babette)](https://cran.r-project.org/package=babette) [![](http://cranlogs.r-pkg.org/badges/grand-total/babette)]( https://CRAN.R-project.org/package=babette) [![](http://cranlogs.r-pkg.org/badges/babette)](https://CRAN.R-project.org/package=babette) -Branch |[![GitHub Actions logo](man/figures/GitHubActions.png)](https://github.com/ropensci/babette/actions)|[![Codecov logo](man/figures/Codecov.png)](https://www.codecov.io) +Branch |[![GitHub Actions logo](man/figures/GitHubActions.png)](https://github.com/ropensci/babette/actions)|[![Codecov logo](man/figures/Codecov.png)](https://about.codecov.io/) ---------|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------- -`master` |![R-CMD-check](https://github.com/ropensci/babette/workflows/R-CMD-check/badge.svg?branch=master) |[![codecov.io](https://codecov.io/github/ropensci/babette/coverage.svg?branch=master)](https://codecov.io/github/ropensci/babette/branch/master) -`develop`|![R-CMD-check](https://github.com/ropensci/babette/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/babette/coverage.svg?branch=develop)](https://codecov.io/github/ropensci/babette/branch/develop) +`master` |![R-CMD-check](https://github.com/ropensci/babette/workflows/R-CMD-check/badge.svg?branch=master) |[![codecov.io](https://codecov.io/github/ropensci/babette/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/babette/branch/master) +`develop`|![R-CMD-check](https://github.com/ropensci/babette/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/babette/coverage.svg?branch=develop)](https://app.codecov.io/github/ropensci/babette/branch/develop) [![DOI](https://zenodo.org/badge/118616108.svg)](https://zenodo.org/badge/latestdoi/118616108) @@ -48,7 +48,7 @@ See: * [lumier](https://github.com/ropensci/lumier): R Shiny app to help create the R function call needed * [examples](https://github.com/richelbilderbeek/babette_examples): examples tested by Travis CI and AppVeyor * [article](https://besjournals.onlinelibrary.wiley.com/doi/abs/10.1111/2041-210X.13032), in 'Methods in Ecology and Evolution' - * [Methods.blog post: The babette R Package: How to Sooth the Phylogenetic BEAST2](https://methodsblog.wordpress.com/2018/06/25/babette-beast2/) + * [Methods.blog post: The babette R Package: How to Sooth the Phylogenetic BEAST2](https://methodsblog.com/2018/06/25/babette-beast2/) * [rOpenSci blog post: Call BEAST2 for Bayesian evolutionary analysis from R](https://ropensci.org/blog/2020/01/28/babette/) * [pre-print article](https://doi.org/10.1101/271866), in bioRxiv * ['babette' YouTube channel](https://www.youtube.com/watch?v=nA-0-Fc95xY&list=PLu8_ZyzXyRDFIRx-kdDI5Q6xVr-HnY7TB) @@ -95,12 +95,12 @@ Sure, just add an Issue. Or send an email. ## Dependencies -Branch |[![GitHub Actions logo](man/figures/GitHubActions.png)](https://github.com/ropensci/babette/actions) `master`|[![GitHub Actions logo](man/figures/GitHubActions.png)](https://github.com/ropensci/babette/actions) `develop`|[![Codecov logo](man/figures/Codecov.png)](https://www.codecov.io) `master` |[![Codecov logo](man/figures/Codecov.png)](https://www.codecov.io) `develop` +Branch |[![GitHub Actions logo](man/figures/GitHubActions.png)](https://github.com/ropensci/babette/actions) `master`|[![GitHub Actions logo](man/figures/GitHubActions.png)](https://github.com/ropensci/babette/actions) `develop`|[![Codecov logo](man/figures/Codecov.png)](https://about.codecov.io/) `master` |[![Codecov logo](man/figures/Codecov.png)](https://about.codecov.io/) `develop` ------------------------------------------------|-------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------- -[beautier](https://github.com/ropensci/beautier)|![R-CMD-check](https://github.com/ropensci/beautier/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/beautier/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/beautier/coverage.svg?branch=master)](https://codecov.io/github/ropensci/beautier/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/beautier/coverage.svg?branch=develop)](https://codecov.io/github/ropensci/beautier/branch/develop) -[beastier](https://github.com/ropensci/beastier)|![R-CMD-check](https://github.com/ropensci/beastier/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/beastier/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/beastier/coverage.svg?branch=master)](https://codecov.io/github/ropensci/beastier/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/beastier/coverage.svg?branch=develop)](https://codecov.io/github/ropensci/beastier/branch/develop) -[mauricer](https://github.com/ropensci/mauricer)|![R-CMD-check](https://github.com/ropensci/mauricer/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/mauricer/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/mauricer/coverage.svg?branch=master)](https://codecov.io/github/ropensci/mauricer/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/mauricer/coverage.svg?branch=develop)](https://codecov.io/github/ropensci/mauricer/branch/develop) -[tracerer](https://github.com/ropensci/tracerer)|![R-CMD-check](https://github.com/ropensci/tracerer/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/tracerer/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/tracerer/coverage.svg?branch=master)](https://codecov.io/github/ropensci/tracerer/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/tracerer/coverage.svg?branch=develop)](https://codecov.io/github/ropensci/tracerer/branch/develop) +[beautier](https://github.com/ropensci/beautier)|![R-CMD-check](https://github.com/ropensci/beautier/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/beautier/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/beautier/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/beautier/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/beautier/coverage.svg?branch=develop)](https://app.codecov.io/github/ropensci/beautier/branch/develop) +[beastier](https://github.com/ropensci/beastier)|![R-CMD-check](https://github.com/ropensci/beastier/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/beastier/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/beastier/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/beastier/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/beastier/coverage.svg?branch=develop)](https://app.codecov.io/github/ropensci/beastier/branch/develop) +[mauricer](https://github.com/ropensci/mauricer)|![R-CMD-check](https://github.com/ropensci/mauricer/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/mauricer/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/mauricer/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/mauricer/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/mauricer/coverage.svg?branch=develop)](https://app.codecov.io/github/ropensci/mauricer/branch/develop) +[tracerer](https://github.com/ropensci/tracerer)|![R-CMD-check](https://github.com/ropensci/tracerer/workflows/R-CMD-check/badge.svg?branch=master) |![R-CMD-check](https://github.com/ropensci/tracerer/workflows/R-CMD-check/badge.svg?branch=develop) |[![codecov.io](https://codecov.io/github/ropensci/tracerer/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/tracerer/branch/master)|[![codecov.io](https://codecov.io/github/ropensci/tracerer/coverage.svg?branch=develop)](https://app.codecov.io/github/ropensci/tracerer/branch/develop) ## Windows @@ -114,9 +114,9 @@ Package | ## Related packages -Package |[![Codecov logo](man/figures/Codecov.png)](https://www.codecov.io) +Package |[![Codecov logo](man/figures/Codecov.png)](https://about.codecov.io/) --------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------- -[lumier](https://github.com/ropensci/lumier)|[![codecov.io](https://codecov.io/github/ropensci/lumier/coverage.svg?branch=master)](https://codecov.io/github/ropensci/lumier/branch/master) +[lumier](https://github.com/ropensci/lumier)|[![codecov.io](https://codecov.io/github/ropensci/lumier/coverage.svg?branch=master)](https://app.codecov.io/github/ropensci/lumier/branch/master) ## External links From 144acdf98cb274821054bdd1cfe07b4f9c8c941e Mon Sep 17 00:00:00 2001 From: olivroy Date: Tue, 19 Dec 2023 14:03:24 -0500 Subject: [PATCH 9/9] update wordlist --- inst/WORDLIST | 1 + 1 file changed, 1 insertion(+) diff --git a/inst/WORDLIST b/inst/WORDLIST index 2db1f3e..9d87beb 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -49,6 +49,7 @@ preprint Rampal reproducibly Richèl +rlang ropensci rOpenSci rmarkdown