Skip to content

Commit

Permalink
Merge develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
hsbadr committed Sep 8, 2023
2 parents f82ba00 + fe8e55a commit 4edebe3
Show file tree
Hide file tree
Showing 305 changed files with 28,585 additions and 88,998 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ name: R-CMD-check
branches:
- develop
- experimental
- StanHeaders_*
pull_request:
branches:
- develop
- experimental
- StanHeaders_*

jobs:
R-CMD-check:
Expand Down Expand Up @@ -80,7 +82,6 @@ jobs:
remotes::install_cran("rcmdcheck")
remotes::install_cran("rstantools", type = "source")
remotes::install_cran("sessioninfo")
remotes::install_github("hsbadr/RcppEigen@develop")
if (utils::packageVersion("sessioninfo") >= "1.2.1") {
sessioninfo::session_info(pkgs = "installed", include_base = TRUE)
} else {
Expand Down
1 change: 1 addition & 0 deletions StanHeaders/.Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ cleanup.win
revdep
install-github.R
inst/doc/.install_extras
vignettes/.install_extras
.*\.o$
.*\.a$
\.gitignore$
Expand Down
2 changes: 1 addition & 1 deletion StanHeaders/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Authors@R: c(person("Ben",family="Goodrich", email="benjamin.goodrich@columbia.e
URL: https://mc-stan.org/
Description: The C++ header files of the Stan project are provided by this package, but it contains little R code or documentation. The main reference is the vignette. There is a shared object containing part of the 'CVODES' library, but its functionality is not accessible from R. 'StanHeaders' is primarily useful for developers who want to utilize the 'LinkingTo' directive of their package's DESCRIPTION file to build on the Stan library without incurring unnecessary dependencies. The Stan project develops a probabilistic programming language that implements full or approximate Bayesian statistical inference via Markov Chain Monte Carlo or 'variational' methods and implements (optionally penalized) maximum likelihood estimation via optimization. The Stan library includes an advanced automatic differentiation scheme, 'templated' statistical and linear algebra functions that can handle the automatically 'differentiable' scalar types (and doubles, 'ints', etc.), and a parser for the Stan language. The 'rstan' package provides user-facing R functions to parse, compile, test, estimate, and analyze Stan models.
Imports: RcppParallel (>= 5.1.4)
Suggests: Rcpp, BH (>= 1.75.0-0), knitr (>= 1.36), rmarkdown, Matrix, methods, rstan
Suggests: Rcpp, BH (>= 1.75.0-0), knitr (>= 1.36), rmarkdown, Matrix, methods, rstan, withr
LinkingTo: RcppEigen (>= 0.3.3.9.3), RcppParallel (>= 5.1.4)
VignetteBuilder: knitr
SystemRequirements: GNU make, pandoc
Expand Down
27 changes: 15 additions & 12 deletions StanHeaders/R/stanFunction.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FALSE,
cacheDir = getOption("rcpp.cache.dir", tempdir()),
cacheDir = getOption("rcpp.cache.dir", tempdir()),
showOutput = verbose, verbose = getOption("verbose")) {
make_type <- function(x, recursive = FALSE) {
is_array <- is.list(x)
Expand Down Expand Up @@ -44,16 +44,16 @@ stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FAL
int_lists <- types == "const std::vector<int >&"
if (any(int_lists)) types[int_lists] <- "const List&"
code <- paste0("auto ", function_name, "(",
paste(types, names(types), collapse = ", "),
") { return stan::math::", function_name, "(",
paste(types, names(types), collapse = ", "),
") { return stan::math::", function_name, "(",
paste(ifelse(double_lists,
paste0("std::vector<double>(", names(types), ".begin(), ",
names(types), ".end())"),
ifelse(int_lists,
paste0("std::vector<int>(", names(types), ".begin(), ",
names(types), ".end())"),
names(types))), collapse = ", "), "); }")
incl <- dir(system.file("include", "stan", "math", "prim",
incl <- dir(system.file("include", "stan", "math", "prim",
package = "StanHeaders", mustWork = TRUE),
pattern = "hpp$")
incl <- setdiff(incl, "core.hpp")
Expand All @@ -66,18 +66,21 @@ stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FAL
on.exit(options(useFancyQuotes = op))
incl <- c(incl, paste0('#include ', dQuote(create_rng)))
code <- sub(") {", ", const int random_seed = 0) {", code, fixed = TRUE)
code <- sub(" return ",
code <- sub(" return ",
"boost::ecuyer1988 base_rng__ = stan::services::util::create_rng(random_seed, 0); return ",
code)
code <- sub("); }", ", base_rng__); }", code, fixed = TRUE)
}
old_USE_CXX14 <- Sys.getenv("USE_CXX14")
on.exit(Sys.setenv(USE_CXX14 = old_USE_CXX14))
Sys.setenv(USE_CXX14 = "1")
Rcpp::cppFunction(code, depends = c("StanHeaders", "RcppEigen", "BH"),
includes = incl, env = env, rebuild = rebuild,
cacheDir = cacheDir,
showOutput = showOutput, verbose = verbose)
withr::with_makevars(
c(
PKG_CXXFLAGS = CxxFlags(as_character = TRUE),
PKG_LIBS = LdFlags(as_character = TRUE)
),
Rcpp::cppFunction(code, depends = c("StanHeaders", "RcppEigen", "BH"),
includes = incl, env = env, rebuild = rebuild,
cacheDir = cacheDir,
showOutput = showOutput, verbose = verbose)
)
if (grepl("_rng$", function_name)) {
fun <- get(function_name, envir = env, mode = "function")
formals(fun, envir = env)$random_seed <- quote(sample.int(.Machine$integer.max, size = 1L))
Expand Down
25 changes: 3 additions & 22 deletions StanHeaders/cleanup
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,11 @@ rm -Rf inst/include/src \
inst/include/stan \
inst/include/libsundials || true

mkdir -p inst/include/src || true
cp -Rf inst/include/upstream/src/stan inst/include/src/stan || true
cp -Rf inst/include/upstream/src inst/include/src || true
cp -Rf inst/include/upstream/lib/stan_math inst/include/mathlib || true
cp -Rf inst/include/upstream/lib/stan_math/stan inst/include/stan || true
cp -Rf inst/include/upstream/lib/stan_math/lib/sundials_* inst/include/libsundials || true
cp -Rf inst/include/upstream/lib/stan_math/lib/sundials_*/include/* inst/include/ || true
cp -Rf inst/include/upstream/lib/stan_math/lib/sundials_*/src/* src/ || true

# Prepare TBB objects and headers
if [ ! -z "STANHEADERS_TBB_STATIC" ] && [ -z "$TBB_LIB" ] && [ ! -d src/tbb ]; then
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/src/tbb* src/ || true
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/src/rml src/ || true
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/include/serial inst/include/ || true
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/include/*tbb* inst/include/ || true
cp -v inst/include/upstream/lib/stan_math/lib/tbb_*/include/*tbb*/*.h inst/include/tbb/ || true
cp -v inst/include/upstream/lib/stan_math/lib/tbb_*/src/tbb/*.h inst/include/tbb/ || true
echo '#define __TBB_VERSION_STRINGS(N) "Empty"' > src/tbb/version_string.ver || true
fi

if [ ! -z "$TBB_LIB" ]; then
rm -Rf src/tbb* || true
rm -Rf src/rml || true
rm -Rf inst/include/serial || true
rm -Rf inst/include/*tbb* || true
fi

rm -Rf inst/include/upstream || true

exit $?
25 changes: 3 additions & 22 deletions StanHeaders/cleanup.win
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,11 @@ rm -Rf inst/include/src \
inst/include/stan \
inst/include/libsundials || true

mkdir -p inst/include/src || true
cp -Rf inst/include/upstream/src/stan inst/include/src/stan || true
cp -Rf inst/include/upstream/src inst/include/src || true
cp -Rf inst/include/upstream/lib/stan_math inst/include/mathlib || true
cp -Rf inst/include/upstream/lib/stan_math/stan inst/include/stan || true
cp -Rf inst/include/upstream/lib/stan_math/lib/sundials_* inst/include/libsundials || true
cp -Rf inst/include/upstream/lib/stan_math/lib/sundials_*/include/* inst/include/ || true
cp -Rf inst/include/upstream/lib/stan_math/lib/sundials_*/src/* src/ || true

# Prepare TBB objects and headers
if [ ! -z "STANHEADERS_TBB_STATIC" ] && [ -z "$TBB_LIB" ] && [ ! -d src/tbb ]; then
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/src/tbb* src/ || true
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/src/rml src/ || true
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/include/serial inst/include/ || true
cp -Rv inst/include/upstream/lib/stan_math/lib/tbb_*/include/*tbb* inst/include/ || true
cp -v inst/include/upstream/lib/stan_math/lib/tbb_*/include/*tbb*/*.h inst/include/tbb/ || true
cp -v inst/include/upstream/lib/stan_math/lib/tbb_*/src/tbb/*.h inst/include/tbb/ || true
echo '#define __TBB_VERSION_STRINGS(N) "Empty"' > src/tbb/version_string.ver || true
fi

if [ ! -z "$TBB_LIB" ]; then
rm -Rf src/tbb* || true
rm -Rf src/rml || true
rm -Rf inst/include/serial || true
rm -Rf inst/include/*tbb* || true
fi

rm -Rf inst/include/upstream || true

exit $?
4 changes: 2 additions & 2 deletions StanHeaders/inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
citHeader("To cite StanHeaders in publications use:")

citEntry(entry = "Misc",
bibentry(bibtype = "Misc",
title = "{StanHeaders}: Headers for the {R} interface to {Stan}",
author = person(given = "Stan Development Team"),
note = "R package version 2.21.0-6",
Expand All @@ -9,5 +9,5 @@ citEntry(entry = "Misc",
textVersion =
paste("Stan Development Team (2018).",
title = "StanHeaders: Headers for the {R} interface to {Stan}.",
"https://mc-stan.org/.")
"https://mc-stan.org/.")
)
2 changes: 1 addition & 1 deletion StanHeaders/inst/include/libsundials
215 changes: 0 additions & 215 deletions StanHeaders/inst/include/serial/tbb/parallel_for.h

This file was deleted.

Loading

0 comments on commit 4edebe3

Please sign in to comment.