From beeb7c77b365751e7ed1a717890340a80c9c2065 Mon Sep 17 00:00:00 2001 From: Daniel Sabanes Bove Date: Thu, 12 Oct 2023 19:31:52 -0400 Subject: [PATCH] try to work without std::make_unique [skip vbump] (#354) --- DESCRIPTION | 5 ++--- NEWS.md | 2 +- R/zzz.R | 18 +++++++++--------- src/Makevars | 1 - src/chol_cache.h | 7 ++++--- vignettes/package_structure.Rmd | 3 +-- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index da7c06b64..4933eb12b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mmrm Title: Mixed Models for Repeated Measures -Version: 0.3.3.9000 +Version: 0.3.4 Authors@R: c( person("Daniel", "Sabanes Bove", , "daniel.sabanes_bove@roche.com", role = c("aut", "cre")), person("Julia", "Dedic", , "julia.dedic@roche.com", role = "aut"), @@ -72,7 +72,7 @@ Suggests: microbenchmark, mockery, parallelly (>= 1.32.0), - parsnip (>= 1.0.4), + parsnip (>= 1.1.0), purrr, rmarkdown, sasr, @@ -97,7 +97,6 @@ LazyData: true NeedsCompilation: yes Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 -SystemRequirements: C++14 Collate: 'between-within.R' 'catch-routine-registration.R' diff --git a/NEWS.md b/NEWS.md index 95cf6c067..04b846671 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,4 @@ -# mmrm 0.3.3.9000 +# mmrm 0.3.4 ### New Features diff --git a/R/zzz.R b/R/zzz.R index 798072a62..836a781b4 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -11,7 +11,7 @@ ) register_on_load( - "parsnip", c("1.0.4", NA), + "parsnip", c("1.1.0", NA), callback = parsnip_add_mmrm, message = emit_tidymodels_register_msg ) @@ -74,24 +74,24 @@ register_on_load <- function(pkg, check_package_version <- function(pkg, ver = c(NA_character_, NA_character_)) { assert_character(ver, len = 2L) pkg_ver <- utils::packageVersion(pkg) - ver <- lapply(ver, numeric_version, strict = FALSE) + ver <- numeric_version(ver, strict = FALSE) warn_version <- function(pkg, pkg_ver, ver) { - ver_na <- is.na(vapply(ver, is.na, logical(1L))) + ver_na <- is.na(ver) warning(sprintf( "Cannot register mmrm for use with %s (v%s). Version %s required.", pkg, pkg_ver, if (!any(ver_na)) { - sprintf("%s to %s", ver[[1]], ver[[2]]) - } else if (!is.na(ver[[1]])) { - paste0(">= ", ver[[1]]) - } else if (!is.na(ver[[2]])) { - paste0("<= ", ver[[1]]) + sprintf("%s to %s", ver[1], ver[2]) + } else if (ver_na[2]) { + paste0(">= ", ver[1]) + } else if (ver_na[1]) { + paste0("<= ", ver[2]) } )) } - if (identical(pkg_ver < ver[[1]], TRUE) || identical(pkg_ver > ver[[2]], TRUE)) { + if (identical(pkg_ver < ver[1], TRUE) || identical(pkg_ver > ver[2], TRUE)) { warn_version(pkg, pkg_ver, ver) return(invisible(FALSE)) } diff --git a/src/Makevars b/src/Makevars index 10f14f23f..0ac0777c4 100644 --- a/src/Makevars +++ b/src/Makevars @@ -1,2 +1 @@ -CXX_STD = CXX14 PKG_CXXFLAGS = -D TMBAD_FRAMEWORK -D EIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS diff --git a/src/chol_cache.h b/src/chol_cache.h index 0aee1aa24..de244f612 100644 --- a/src/chol_cache.h +++ b/src/chol_cache.h @@ -3,6 +3,7 @@ #include "covariance.h" #include "utils.h" + // Base class of spatial and non-spatial Cholesky. template struct lower_chol_base { @@ -98,7 +99,7 @@ struct lower_chol_spatial: virtual lower_chol_base { template struct cache_obj { - std::map> cache; + std::map> cache; int n_groups; bool is_spatial; int n_visits; @@ -108,9 +109,9 @@ struct cache_obj { for (int r = 0; r < n_groups; r++) { // Use unique pointers here to better manage resource. if (is_spatial) { - this->cache[r] = std::make_unique(theta.segment(r * theta_one_group_size, theta_one_group_size), cov_type); + this->cache[r] = std::make_shared(theta.segment(r * theta_one_group_size, theta_one_group_size), cov_type); } else { - this->cache[r] = std::make_unique(theta.segment(r * theta_one_group_size, theta_one_group_size), n_visits, cov_type); + this->cache[r] = std::make_shared(theta.segment(r * theta_one_group_size, theta_one_group_size), n_visits, cov_type); } } } diff --git a/vignettes/package_structure.Rmd b/vignettes/package_structure.Rmd index 9cf7fabdd..367a008e3 100644 --- a/vignettes/package_structure.Rmd +++ b/vignettes/package_structure.Rmd @@ -128,8 +128,7 @@ This file implements the `P`, `Q` and `R` matrix calculations which are needed f ### `Makevars` This file specifies additional flags used in the source code compilation. -We specify here the use of `C++14` such that `std::make_unique()` is available. -Also we ask `TMB` to use the `TMB` automatic differentiation framework (instead of the default `CppAD` framework) to be more efficient, and disable useless warnings from the `Eigen` library compilation. +We ask `TMB` to use the `TMB` automatic differentiation framework (instead of the default `CppAD` framework) to be more efficient, and disable useless warnings from the `Eigen` library compilation. Note that additional flags such as `-Wno-ignored-attributes` cannot be included here because they are compiler specific. These can instead be specified in local `~/.R/Makevars` files.