Skip to content

Commit

Permalink
only if TMB has sufficient version
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinteractive committed Sep 27, 2024
1 parent 3b4542a commit 3e07c7a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -526,16 +526,19 @@ h_drop_levels <- function(data, subject_var, visit_var, except) {

#' Warn if TMB is Configured to Use Non-Deterministic Hash for Tape Optimizer
#'
#' This function checks the TMB configuration for the `tmbad_deterministic_hash` setting.
#' This function checks the TMB configuration for the `tmbad_deterministic_hash` setting
#' If it is set to `FALSE`, a warning is issued indicating that this may lead to
#' unreproducible results.
#'
#' @return No return value, called for side effects.
#' @keywords internal
h_tmb_warn_non_deterministic <- function() {
if (packageVersion("TMB") < "1.9.15") {
return()
}
tmb_config <- TMB::config(DLL = "mmrm")
tape_deterministic <- tmb_config$tmbad_deterministic_hash
if (is.null(tape_deterministic) || !tape_deterministic) {
if (!tape_deterministic) {
msg <- paste(
"TMB is configured to use a non-deterministic hash for its tape optimizer,",
"and this may lead to unreproducible results.",
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ test_that("h_drop_levels works as expected", {
# h_tmb_warn_non_deterministic ----

test_that("h_tmb_warn_non_deterministic works as expected", {
skip_if(packageVersion("TMB") < "1.9.15")
TMB::config(tmbad_deterministic_hash = 0, DLL = "mmrm")
expect_warning(
h_tmb_warn_non_deterministic(),
Expand Down

0 comments on commit 3e07c7a

Please sign in to comment.