Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronise experimental branch #1148

Merged
merged 110 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
e6c21db
Stan v2.32.2
hsbadr Sep 30, 2023
d207caf
Stan to C++ compiler (`stanc3`) v2.32.2
hsbadr Sep 30, 2023
cba4e2b
Version `2.32.2`
hsbadr Sep 30, 2023
ac5eb2f
Update stan submodule
hsbadr Oct 2, 2023
2c2fa32
Update stan submodule
hsbadr Oct 5, 2023
1fea3fd
Merge `develop` branch
hsbadr Oct 6, 2023
796f868
Merge `develop` branch
hsbadr Oct 6, 2023
61fa08f
Update stan submodule
hsbadr Oct 6, 2023
60a231e
use try() instead of file.exists()
bgoodri Oct 10, 2023
7403cc8
revert to stanc.js from 2.26.x
bgoodri Oct 10, 2023
4a3e9be
Update stan submodule
hsbadr Oct 10, 2023
98ff606
Update stan submodule
hsbadr Oct 13, 2023
aa98465
fix braces in Rd files
bgoodri Oct 14, 2023
7d69aad
use an outFile in try()
bgoodri Oct 14, 2023
2cd45b0
Revert "use an outFile in try()"
bgoodri Oct 15, 2023
350ef0d
check StanHeaders version number
bgoodri Oct 15, 2023
b670ff8
stanFunction.R{d}: support complex arguments
bgoodri Oct 15, 2023
506731b
fix Makevars.win
bgoodri Oct 15, 2023
78f0aca
stanFunction.R: use Eigen's typedefs
bgoodri Oct 15, 2023
b881de6
fix vignettes
bgoodri Oct 15, 2023
0daf9e3
Makevars.win: --allow-multiple-definition
bgoodri Oct 15, 2023
5895533
stanmath.Rmd: add reduce_sum example
bgoodri Oct 15, 2023
1a6b5af
fix crash with reduce_sum()
bgoodri Oct 15, 2023
63eddee
Merge updates from `StanHeaders_2.32` branch
hsbadr Oct 16, 2023
27c92c7
Update stan submodule
hsbadr Oct 18, 2023
9584540
Update stan submodule
hsbadr Oct 25, 2023
6306316
Update stan submodule
hsbadr Oct 27, 2023
e2c534b
Update stan submodule
hsbadr Nov 3, 2023
452e536
Update stan submodule
hsbadr Nov 7, 2023
f72473b
Update stan submodule
hsbadr Nov 8, 2023
4b6ede6
Update stan submodule
hsbadr Nov 13, 2023
59f4c2c
Update stan submodule
hsbadr Dec 6, 2023
f229fdd
`rstan`: `io`: Fix type conversion warning
hsbadr Dec 10, 2023
b43a9f7
Update stan submodule
hsbadr Dec 10, 2023
1f12c47
Update stan submodule
hsbadr Dec 12, 2023
509755e
Update stan submodule
hsbadr Dec 19, 2023
cc08829
Update stan submodule
hsbadr Dec 20, 2023
8c09564
Update stan submodule
hsbadr Dec 23, 2023
5020cc8
Update stan submodule
hsbadr Jan 6, 2024
e6d0d2e
Update stan submodule
hsbadr Jan 8, 2024
36a51cb
Merge remote-tracking branch 'develop'
hsbadr Jan 12, 2024
125a3c4
Update stan submodule
hsbadr Jan 17, 2024
8e49ac7
Stan to C++ compiler (`stanc3`) v2.34.0
hsbadr Jan 17, 2024
a3a1dca
`rstan`: Update `NEWS`
hsbadr Jan 17, 2024
a85c64a
Versin `2.34.0`
hsbadr Jan 17, 2024
3a94f4a
Update stan submodule
hsbadr Jan 19, 2024
da412a0
Update stan submodule
hsbadr Jan 22, 2024
37f42cd
Merge `develop` branch
hsbadr Jan 23, 2024
c2ce634
Update stan submodule
hsbadr Jan 25, 2024
ca3adef
Update stan submodule
hsbadr Jan 28, 2024
faee503
Update stan submodule
hsbadr Jan 30, 2024
9106582
Update stan submodule
hsbadr Feb 1, 2024
6e71c40
Update stan submodule
hsbadr Feb 3, 2024
13e9bb8
Update stan submodule
hsbadr Feb 4, 2024
4a657fe
Merge `develop` branch
hsbadr Feb 8, 2024
c5d0659
Update stan submodule
hsbadr Feb 8, 2024
5c99eef
Merge `develop` branch
hsbadr Feb 9, 2024
e6ba6ca
Update stan submodule
hsbadr Feb 9, 2024
2689023
Update stan submodule
hsbadr Feb 13, 2024
6591339
Update stan submodule
hsbadr Feb 15, 2024
59006c4
Change default RNG to `boost::mixmax`
hsbadr Feb 15, 2024
68f8bee
Update stan submodule
hsbadr Feb 18, 2024
9e86bcf
Update stan submodule
hsbadr Feb 19, 2024
419b378
GHA: Update actions
hsbadr Feb 19, 2024
8561e6d
Update stan submodule
hsbadr Mar 22, 2024
cdf2317
Update stan submodule
hsbadr Mar 28, 2024
5cb64ff
Update stan submodule
hsbadr May 13, 2024
a1bd397
Update `stanc3` JS
hsbadr May 13, 2024
3d8cc52
Bump version `2.35.0`
hsbadr May 13, 2024
3fa1d0f
`rstan`: Update `NEWS`
hsbadr May 13, 2024
d41a406
Fixes: GHA workflow (use r-lib recipes), r-devel compilation with R_N…
andrjohns May 20, 2024
5117344
Update flags to support Windows ARM64
andrjohns May 20, 2024
2b4258d
Try adding .prepare script for r-universe build
andrjohns May 20, 2024
5770c8e
Try .prepare script
andrjohns May 20, 2024
e84011f
Working prepare script for r-universe build
andrjohns May 20, 2024
b3b016e
Update stan submodule
hsbadr May 24, 2024
90040d3
Update `stanc3` JS
hsbadr May 24, 2024
2a25c2d
`rstan`: Update `NEWS`
hsbadr May 24, 2024
90ca993
Update stan submodule
hsbadr Jun 6, 2024
1c17618
Update `stanc3` JS
hsbadr Jun 6, 2024
cf68ba6
`rstan`: Update `NEWS`
hsbadr Jun 6, 2024
e41bcdf
Update stan submodule
hsbadr Jun 22, 2024
0fac1c7
Update stan submodule
hsbadr Jun 25, 2024
c1a8929
Update stan submodule
hsbadr Jun 27, 2024
79c6ccb
Update stan submodule
hsbadr Jun 29, 2024
15ed304
Update stan submodule
hsbadr Jul 2, 2024
bed4ab0
Update stan submodule
hsbadr Jul 11, 2024
7ccff3e
Update stan submodule
hsbadr Jul 12, 2024
7067bcb
Update stan submodule
hsbadr Jul 18, 2024
90be8dc
Merge updates from `develop` branch
hsbadr Jul 20, 2024
34279a7
Revert "Merge updates from `develop` branch"
hsbadr Jul 20, 2024
fc414f9
`stan`: `csv`: Protect conditionals for `save_warmup`
hsbadr Jul 20, 2024
7d850e8
Update stan submodule
hsbadr Jul 26, 2024
086e05e
Update stan submodule
hsbadr Jul 28, 2024
d080b13
Update stan submodule
hsbadr Aug 1, 2024
2673051
Update stan submodule
hsbadr Aug 13, 2024
596e95e
Update stan submodule
hsbadr Aug 28, 2024
fd803f1
Update stan submodule
hsbadr Oct 2, 2024
21f62ea
Update stan submodule
hsbadr Oct 7, 2024
d8bceb8
Update stan submodule
hsbadr Oct 23, 2024
9a64492
Update stan submodule
hsbadr Oct 31, 2024
94e0b29
Update stan submodule
hsbadr Nov 2, 2024
7dd184d
Update stan submodule
hsbadr Nov 22, 2024
1d2f4d2
Update stan submodule
hsbadr Nov 23, 2024
a78e986
Update `stanc3` JS
hsbadr Nov 23, 2024
b6172e5
Update stan submodule
hsbadr Dec 1, 2024
2a83be6
Update `stanc3` JS
hsbadr Dec 1, 2024
05e89d9
Bump version `2.36.0`
hsbadr Dec 1, 2024
e094306
Update stan submodule
hsbadr Jan 12, 2025
7ffa7fc
Update `stanc3` JS
hsbadr Jan 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
161 changes: 31 additions & 130 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,162 +27,63 @@ jobs:
fail-fast: true
matrix:
config:
- {os: macOS-latest, r: 'devel'}
- {os: macOS-latest, r: 'release'}
- {os: macOS-latest, r: 'oldrel'}
- {os: windows-latest, r: 'devel'}
- {os: windows-latest, r: 'release'}
- {os: windows-latest, r: 'oldrel'}
- {os: ubuntu-20.04, r: 'devel'}
- {os: ubuntu-20.04, r: 'release'}
- {os: ubuntu-20.04, r: 'oldrel'}
- {os: ubuntu-latest, r: 'devel'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

- uses: r-lib/actions/setup-pandoc@v2

- name: Query dependencies
# Use a shorter temp directory for pak installations, due to filename
# length issues on Windows. https://github.com/r-lib/pak/issues/252
- name: Windows temp dir
if: runner.os == 'Windows'
run: |
options(install.packages.check.source = "no")
options(pkgType = ifelse(grepl("linux", R.version$os), "source", "binary"))
install.packages('remotes')
install.packages('V8')
saveRDS(remotes::dev_package_deps(pkg = "./rstan/rstan", dependencies = TRUE), ".github/depends.Rds", version = 2)
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
shell: Rscript {0}
New-Item -Path "C:\" -Name "tmp" -ItemType Directory
echo "TMPDIR=c:\tmp" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v2
- uses: r-lib/actions/setup-r-dependencies@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
working-directory: rstan/rstan
extra-packages: any::rcmdcheck, local::../../StanHeaders

- name: Install system dependencies
if: runner.os == 'Linux'
env:
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
- name: Remove symlinks on Windows
if: runner.os == 'Windows'
run: |
Rscript -e "remotes::install_github('r-hub/sysreqs')"
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('./rstan/rstan/DESCRIPTION'))")
sudo -s eval "$sysreqs"
rm -Rf inst/include/src \
inst/include/mathlib \
inst/include/stan \
inst/include/libsundials || true
shell: bash

- name: Install dependencies
run: |
remotes::install_deps(pkg = "./rstan/rstan", dependencies = TRUE)
remotes::install_cran("rcmdcheck")
remotes::install_cran("rstantools", type = "source")
remotes::install_cran("sessioninfo")
if (utils::packageVersion("sessioninfo") >= "1.2.1") {
sessioninfo::session_info(pkgs = "installed", include_base = TRUE)
} else {
options(width = 200)
sessioninfo::session_info(rownames(installed.packages()), include_base = TRUE)
}
shell: Rscript {0}

- name: Install StanHeaders
run: |
try(system("sh sh_b.sh --no-build-vignettes --no-manual"))
shell: Rscript {0}

- name: Session info
run: |
options(width = 100)
pkgs <- installed.packages()[, "Package"]
sessioninfo::session_info(pkgs, include_base = TRUE)
shell: Rscript {0}

- name: Verify Math Version
run: |
readLines(system.file("include","stan","math","version.hpp", package="StanHeaders"))
shell: Rscript {0}

- name: Check
- uses: r-lib/actions/check-r-package@v2
with:
working-directory: StanHeaders
error-on: '"error"'
env:
_R_CHECK_CRAN_INCOMING_: false
run: |
if (R.version$major < 4 && isTRUE(.Platform$OS.type == "windows")) {
dotR <- file.path(Sys.getenv("HOME"), ".R")
if (!file.exists(dotR)) dir.create(dotR)
path_makevars <- ifelse(.Platform$OS.type == "windows", "Makevars.win", "Makevars")
M <- file.path(dotR, path_makevars)
if (!file.exists(M)) file.create(M)
cat("\nCXX14FLAGS=-O3",
"CXX14 = $(BINPREF)g++ -m$(WIN) -std=c++1y",
"CXX11FLAGS=-O3",
file = M, sep = "\n", append = TRUE)
}
rcmdcheck::rcmdcheck(path = "./rstan/rstan", args = c("--no-manual", "--as-cran", "--ignore-vignettes"), build_args = c("--no-build-vignettes"), error_on = "warning", check_dir = "check")
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
rm -rf check/rstan.Rcheck/rstan check/rstan.Rcheck/*pkg_src
find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload check results
if: failure()
uses: actions/upload-artifact@v2
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check

- name: Extract version and check StanHeaders source package
run: |
set -x
echo "STANHEADERS_VERSION=$(grep '^Version' StanHeaders/DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
echo "RSTAN_VERSION=$(grep '^Version' rstan/rstan/DESCRIPTION | sed 's/.*: *//')" >> $GITHUB_ENV
if [[ ! -f StanHeaders_*.tar.gz ]]; then
sh sh_b.sh --no-build-vignettes --no-manual || true
fi
mkdir -p build || true
cp -v StanHeaders_*.tar.gz build/ || true
ls -R build/
shell: bash

- name: Build RStan source package
if: matrix.config.os == 'ubuntu-20.04' && matrix.config.r == 'devel'
run: |
src_rstan <- pkgbuild::build("./rstan/rstan", dest_path = tempdir(), vignettes = FALSE, manual = FALSE)
file.copy(src_rstan, "build")
shell: Rscript {0}

- name: Build binary packages
run: |
bin1 <- pkgbuild::build("./build/StanHeaders_${{ env.STANHEADERS_VERSION }}.tar.gz", dest_path = tempdir(), vignettes = FALSE, manual = FALSE, binary = TRUE)
bin2 <- pkgbuild::build("./rstan/rstan", dest_path = tempdir(), vignettes = FALSE, manual = FALSE, binary = TRUE)
dir.create("build_bin")
file.copy(c(bin1, bin2), "build_bin")
shell: Rscript {0}

- name: Upload StanHeaders source package
if: matrix.config.os == 'ubuntu-20.04' && matrix.config.r == 'devel'
uses: actions/upload-artifact@v2
with:
name: StanHeaders_${{ env.STANHEADERS_VERSION }}.tar.gz
path: build/StanHeaders_${{ env.STANHEADERS_VERSION }}.tar.gz

- name: Upload RStan source package
if: matrix.config.os == 'ubuntu-20.04' && matrix.config.r == 'devel'
uses: actions/upload-artifact@v2
with:
name: rstan_${{ env.RSTAN_VERSION }}.tar.gz
path: build/rstan_${{ env.RSTAN_VERSION }}.tar.gz
working-directory: rstan/rstan
env:
_R_CHECK_CRAN_INCOMING_: false

- name: Upload binary packages
uses: actions/upload-artifact@v2
with:
name: R-${{ matrix.config.r }}_${{ matrix.config.os }}
path: build_bin
5 changes: 5 additions & 0 deletions StanHeaders/.prepare
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

git checkout experimental
cd inst/include/upstream && git checkout develop && git pull && cd ../../..
cd inst/include/upstream/lib/stan_math && git checkout develop && git pull && cd ../../../../..
2 changes: 1 addition & 1 deletion StanHeaders/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: StanHeaders
Title: C++ Header Files for Stan
Version: 2.33.1.9000
Version: 2.36.0.9000
Authors@R: c(person("Ben",family="Goodrich", email="[email protected]", role=c('cre','aut')),
person("Joshua", "Pritikin", role = "ctb"),
person("Andrew", "Gelman", role = "aut"),
Expand Down
12 changes: 11 additions & 1 deletion StanHeaders/R/Flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ CxxFlags <- function(as_character = FALSE) {
CXXFLAGS <- paste0("-I", shQuote(TBB_INC), " -D_REENTRANT -DSTAN_THREADS -DTBB_INTERFACE_NEW")
} else {
CXXFLAGS <- paste0("-I", shQuote(TBB_INC), " -D_REENTRANT -DSTAN_THREADS")
# RcppParallel TBB does not have assembly code for Windows ARM64
# so we need to use compiler builtins
if (.Platform$OS.type == "windows" && R.version$arch == "aarch64") {
CXXFLAGS <- paste(CXXFLAGS, "-DTBB_USE_GCC_BUILTINS")
}
}

if (isTRUE(as_character)) return(CXXFLAGS)
Expand All @@ -24,7 +29,12 @@ LdFlags <- function(as_character = FALSE) {
TBB_LIB <- system.file("lib", .Platform$r_arch, package = "RcppParallel", mustWork = TRUE)
}

PKG_LIBS <- paste0("-L", shQuote(TBB_LIB), " -Wl,-rpath,", shQuote(TBB_LIB), " -ltbb -ltbbmalloc")
PKG_LIBS <- paste0("-L", shQuote(TBB_LIB))
# RTools aarch64 does not support rpath, but it is not used on Windows anyway
if (!(.Platform$OS.type == "windows" && R.version$arch == "aarch64")) {
PKG_LIBS <- paste0(PKG_LIBS, " -Wl,-rpath,", shQuote(TBB_LIB))
}
PKG_LIBS <- paste0(PKG_LIBS, " -ltbb -ltbbmalloc")

if (isTRUE(as_character)) return(PKG_LIBS)
cat(PKG_LIBS, " ")
Expand Down
38 changes: 28 additions & 10 deletions StanHeaders/R/stanFunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,30 @@ stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FAL
Eigen <- FALSE
if (is.matrix(x)) {
Eigen <- TRUE
if (nrow(x) == 1L) type <- "stan::math::row_vector_d"
else type <- "stan::math::matrix_d"
if (is.complex(x)) {
if (nrow(x) == 1L) {
type <- "Eigen::Matrix<std::complex<double>, 1, -1>"
} else type <- "Eigen::MatrixXcd"
} else if (nrow(x) == 1L) {
type <- "stan::math::row_vector_d"
} else type <- "stan::math::matrix_d"
} else if (length(x) > 1L) {
if (is.integer(x)) {
type <- "std::vector<int>"
} else {
Eigen <- TRUE
type <- "stan::math::vector_d"
if (is.complex(x)) {
type <- "Eigen::VectorXcd"
} else type <- "stan::math::vector_d"
}
} else if (is.integer(x)) {
type <- "int"
} else if (is.numeric(x)) {
type <- "double"
} else if (is.complex(x)) {
type <- "std::complex<double>"
} else stop(paste("all arguments to", function_name, "must be matrices,",
"vectors, integers, doubles or lists thereof"))
"vectors, integers, doubles, complexes, or lists thereof"))
if (Eigen) type <- paste0("const ", type, "&")
else type <- paste0("const ", type)
return(type)
Expand All @@ -43,6 +52,8 @@ stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FAL
if (any(double_lists)) types[double_lists] <- "const List&"
int_lists <- types == "const std::vector<int >&"
if (any(int_lists)) types[int_lists] <- "const List&"
complex_lists <- types == "const std::vector<std::complex<double> >&"
if (any(complex_lists)) types[complex_lists] <- "const List&"
code <- paste0("auto ", function_name, "(",
paste(types, names(types), collapse = ", "),
") { return stan::math::", function_name, "(",
Expand All @@ -52,7 +63,11 @@ stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FAL
ifelse(int_lists,
paste0("std::vector<int>(", names(types), ".begin(), ",
names(types), ".end())"),
names(types))), collapse = ", "), "); }")
ifelse(complex_lists,
paste0("std::vector<complex<double>(",
names(types), ".begin(), ",
names(types), ".end())"),
names(types)))), collapse = ", "), "); }")
incl <- dir(system.file("include", "stan", "math", "prim",
package = "StanHeaders", mustWork = TRUE),
pattern = "hpp$")
Expand All @@ -67,18 +82,21 @@ stanFunction <- function(function_name, ..., env = parent.frame(), rebuild = FAL
incl <- c(incl, paste0('#include ', dQuote(create_rng)))
code <- sub(") {", ", const int random_seed = 0) {", code, fixed = TRUE)
code <- sub(" return ",
"boost::ecuyer1988 base_rng__ = stan::services::util::create_rng(random_seed, 0); return ",
"boost::random::mixmax base_rng__ = stan::services::util::create_rng(random_seed, 0); return ",
code)
code <- sub("); }", ", base_rng__); }", code, fixed = TRUE)
}
withr::with_makevars(
c(
PKG_CXXFLAGS = CxxFlags(as_character = TRUE),
PKG_LIBS = LdFlags(as_character = TRUE)
PKG_LIBS = LdFlags(as_character = TRUE),
USE_CXX17 = 1
),
Rcpp::cppFunction(code, depends = c("StanHeaders", "RcppEigen", "BH"),
includes = incl, env = env, rebuild = rebuild,
cacheDir = cacheDir,
Rcpp::cppFunction(code,
depends = c("StanHeaders", "RcppEigen", "BH"),
plugins = "cpp17",
includes = incl,
env = env, rebuild = rebuild, cacheDir = cacheDir,
showOutput = showOutput, verbose = verbose)
)
if (grepl("_rng$", function_name)) {
Expand Down
1 change: 0 additions & 1 deletion StanHeaders/inst/include/libsundials

This file was deleted.

1 change: 0 additions & 1 deletion StanHeaders/inst/include/mathlib

This file was deleted.

1 change: 0 additions & 1 deletion StanHeaders/inst/include/src

This file was deleted.

1 change: 0 additions & 1 deletion StanHeaders/inst/include/stan

This file was deleted.

2 changes: 1 addition & 1 deletion StanHeaders/inst/include/upstream
Submodule upstream updated 188 files
Loading
Loading