From b4da4785ceaa32fc26986125d52433ed04e94dfe Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Apr 2024 22:50:01 +0300 Subject: [PATCH 1/4] Fix stanfunctions failures with new Stan RNG --- R/rstan_config.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/rstan_config.R b/R/rstan_config.R index a73d684..c21e1f5 100644 --- a/R/rstan_config.R +++ b/R/rstan_config.R @@ -217,6 +217,8 @@ rstan_config <- function(pkgdir = ".") { cat("#include ", eigen_incl, "#include ", + # Make stan::rng_t typedef available + "#include ", file = file.path(pkgdir, "src", paste(basename(pkgdir), "types.h", sep = "_")), sep = "\n") @@ -236,6 +238,7 @@ rstan_config <- function(pkgdir = ".") { } else { cppcode <- c("#include ", cppcode) } + cppcode <- gsub("boost::ecuyer1988", "stan::rng_t", cppcode, fixed = TRUE) # Stan header file hdr_name <- .stan_prefix(model_name, ".h") # get license file (if any) @@ -275,7 +278,7 @@ rstan_config <- function(pkgdir = ".") { header = paste0('#include "', hdr_name, '"'), module = paste0("stan_fit4", model_name, "_mod"), - CppClass = "rstan::stan_fit ", + CppClass = "rstan::stan_fit ", Rfile = FALSE) ) }) From 7584c4de636645bdf7661ecf940e8ea28fdda275 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Apr 2024 23:07:16 +0300 Subject: [PATCH 2/4] Correctly handle different version availabilities --- R/rstan_config.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/rstan_config.R b/R/rstan_config.R index c21e1f5..87f8750 100644 --- a/R/rstan_config.R +++ b/R/rstan_config.R @@ -217,8 +217,6 @@ rstan_config <- function(pkgdir = ".") { cat("#include ", eigen_incl, "#include ", - # Make stan::rng_t typedef available - "#include ", file = file.path(pkgdir, "src", paste(basename(pkgdir), "types.h", sep = "_")), sep = "\n") @@ -238,7 +236,9 @@ rstan_config <- function(pkgdir = ".") { } else { cppcode <- c("#include ", cppcode) } - cppcode <- gsub("boost::ecuyer1988", "stan::rng_t", cppcode, fixed = TRUE) + if (utils::packageVersion('StanHeaders') >= "2.34") { + cppcode <- gsub("boost::ecuyer1988", "stan::rng_t", cppcode, fixed = TRUE) + } # Stan header file hdr_name <- .stan_prefix(model_name, ".h") # get license file (if any) @@ -278,7 +278,7 @@ rstan_config <- function(pkgdir = ".") { header = paste0('#include "', hdr_name, '"'), module = paste0("stan_fit4", model_name, "_mod"), - CppClass = "rstan::stan_fit ", + CppClass = "rstan::stan_fit ", Rfile = FALSE) ) }) From 65a033467712f52d116c4fe777709b3b7af468ae Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Apr 2024 23:35:51 +0300 Subject: [PATCH 3/4] Speedup cloning experimental rstan --- .github/workflows/check-standalone.yaml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-standalone.yaml b/.github/workflows/check-standalone.yaml index 60afb95..861e200 100644 --- a/.github/workflows/check-standalone.yaml +++ b/.github/workflows/check-standalone.yaml @@ -73,11 +73,18 @@ jobs: rcmdcheck::rcmdcheck(path = "lgpr", args = c("--no-manual", "--as-cran"), build_args = "--no-manual") shell: Rscript {0} + - name: Checkout RStan Experimental branch + uses: actions/checkout@v3 + with: + repository: stan-dev/rstan + ref: experimental + path: ~/rstan + - name: Install Experimental StanHeaders and Experimental RStan run: | Sys.setenv(MAKEFLAGS=paste0("-j",parallel::detectCores())) - remotes::install_github("stan-dev/rstan@experimental", subdir="StanHeaders") - remotes::install_github("stan-dev/rstan@experimental", subdir="rstan/rstan") + install.packages("~/rstan/StanHeaders", type = "source", repos = NULL) + install.packages("~/rstan/rstan/rstan", type = "source", repos = NULL) shell: Rscript {0} - name: Check against Experimental StanHeaders and Experimental RStan From 0ffaf3391d78e6b7e7c090bb866a42b54dfde1a2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 23 Apr 2024 00:59:01 +0300 Subject: [PATCH 4/4] Forgot to checkout rstan submodules --- .github/workflows/check-standalone.yaml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/check-standalone.yaml b/.github/workflows/check-standalone.yaml index 861e200..55b09f7 100644 --- a/.github/workflows/check-standalone.yaml +++ b/.github/workflows/check-standalone.yaml @@ -78,13 +78,14 @@ jobs: with: repository: stan-dev/rstan ref: experimental - path: ~/rstan + path: rstan + submodules: 'recursive' - name: Install Experimental StanHeaders and Experimental RStan run: | Sys.setenv(MAKEFLAGS=paste0("-j",parallel::detectCores())) - install.packages("~/rstan/StanHeaders", type = "source", repos = NULL) - install.packages("~/rstan/rstan/rstan", type = "source", repos = NULL) + install.packages("rstan/StanHeaders", type = "source", repos = NULL) + install.packages("rstan/rstan/rstan", type = "source", repos = NULL) shell: Rscript {0} - name: Check against Experimental StanHeaders and Experimental RStan