From 1bde73d0a1376bf8cb259f3c3aa0c9d7b0a87bf6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 7 Jun 2024 09:51:59 -0400 Subject: [PATCH] Update Stan to 2.35 (#235) * Bump stan from `cc7c617` to `9890ac0` Bumps [stan](https://github.com/stan-dev/stan) from `cc7c617` to `9890ac0`. - [Release notes](https://github.com/stan-dev/stan/releases) - [Commits](https://github.com/stan-dev/stan/compare/cc7c61778af07eac9f30179379c6d78b58e015c3...9890ac0d3f944dcaabce702a8a189be311e2372b) --- updated-dependencies: - dependency-name: stan dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Updates for Stan RNG changes * mingw32-make is no longer required on Windows, use make where applicable * Reset cache version * Format fixes --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Brian Ward --- .github/workflows/main.yaml | 13 +++---------- Makefile | 2 +- R/R/compile.R | 2 +- README.md | 2 +- docs/getting-started.rst | 5 +---- julia/src/compile.jl | 2 +- python/bridgestan/compile.py | 5 +---- rust/src/compile.rs | 6 +----- src/bridgestan.cpp | 2 +- src/model_rng.cpp | 3 +-- src/model_rng.hpp | 17 +++++++++-------- stan | 2 +- 12 files changed, 22 insertions(+), 39 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 91701746..475bde59 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -8,7 +8,7 @@ on: workflow_dispatch: {} env: - CACHE_VERSION: 1 + CACHE_VERSION: 0 # only run one copy per PR concurrency: @@ -58,17 +58,10 @@ jobs: path: ./test_models/ key: ${{ hashFiles('**/*.stan', 'src/*', 'stan/src/stan/version.hpp', 'Makefile') }}-${{ matrix.os }}-v${{ env.CACHE_VERSION }} - - name: Build test models (Unix) - if: matrix.os != 'windows-latest' && steps.test-models.outputs.cache-hit != 'true' + - name: Build test models + if: steps.test-models.outputs.cache-hit != 'true' run: | make STAN_THREADS=true O=0 test_models -j4 - shell: bash - - - name: Build test models (Windows) - if: matrix.os == 'windows-latest' && steps.test-models.outputs.cache-hit != 'true' - run: | - mingw32-make.exe STAN_THREADS=true O=0 test_models -j4 - shell: pwsh python: needs: [build] diff --git a/Makefile b/Makefile index 09b6788a..e7cc87dc 100644 --- a/Makefile +++ b/Makefile @@ -136,7 +136,7 @@ print-% : ; @echo $* = $($*) ; STANC_DL_RETRY = 5 STANC_DL_DELAY = 10 STANC3_TEST_BIN_URL ?= -STANC3_VERSION ?= v2.34.0 +STANC3_VERSION ?= v2.35.0 ifeq ($(OS),Windows_NT) OS_TAG := windows diff --git a/R/R/compile.R b/R/R/compile.R index b94c8222..86259bf8 100644 --- a/R/R/compile.R +++ b/R/R/compile.R @@ -1,5 +1,5 @@ IS_WINDOWS <- isTRUE(.Platform$OS.type == "windows") -MAKE <- Sys.getenv("MAKE", ifelse(IS_WINDOWS, "mingw32-make", "make")) +MAKE <- Sys.getenv("MAKE", "make") verify_bridgestan_path <- function(path) { diff --git a/README.md b/README.md index 2e411454..d1f9d8f1 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Stan is a probabilistic programming language for coding statistical models. For an introduction to what can be coded in Stan, see the [*Stan User's Guide*](https://mc-stan.org/docs/stan-users-guide/index.html). -BridgeStan is currently shipping with Stan version 2.34.1 +BridgeStan is currently shipping with Stan version 2.35.0 Documentation is available at https://roualdes.github.io/bridgestan/ diff --git a/docs/getting-started.rst b/docs/getting-started.rst index b01ea0fc..8b0b8c05 100644 --- a/docs/getting-started.rst +++ b/docs/getting-started.rst @@ -8,7 +8,7 @@ Requirement: C++ toolchain Stan requires a C++ tool chain consisting of * A C++14 compiler. On Windows, MSCV is *not* supported, so something like MinGW GCC is required. -* The Gnu :command:`make` utility for \*nix *or* :command:`mingw32-make` for Windows +* The Gnu :command:`make` utility. On Windows, :command:`make` or :command:`mingw32-make` can be used Here are complete instructions by platform for installing both, from the CmdStan installation instructions. @@ -63,10 +63,7 @@ a terminal in your BridgeStan folder and running .. code-block:: shell - # MacOS and Linux make test_models/multi/multi_model.so - # Windows - mingw32-make.exe test_models/multi/multi_model.so This will compile the file :file:`test_models/multi/multi.stan` into a shared library object for use with BridgeStan. This will require internet access the first time you run it in order diff --git a/julia/src/compile.jl b/julia/src/compile.jl index 5baf18a6..29da70e1 100644 --- a/julia/src/compile.jl +++ b/julia/src/compile.jl @@ -1,6 +1,6 @@ function get_make() - get(ENV, "MAKE", Sys.iswindows() ? "mingw32-make.exe" : "make") + get(ENV, "MAKE", "make") end diff --git a/python/bridgestan/compile.py b/python/bridgestan/compile.py index 527c68b0..6483da2c 100644 --- a/python/bridgestan/compile.py +++ b/python/bridgestan/compile.py @@ -29,10 +29,7 @@ def verify_bridgestan_path(path: Union[str, os.PathLike]) -> None: IS_WINDOWS = platform.system() == "Windows" WINDOWS_PATH_SET = False -MAKE = os.getenv( - "MAKE", - "make" if not IS_WINDOWS else "mingw32-make", -) +MAKE = os.getenv("MAKE", "make") def set_bridgestan_path(path: Union[str, os.PathLike]) -> None: diff --git a/rust/src/compile.rs b/rust/src/compile.rs index 7ba3c715..b1fe7dd7 100644 --- a/rust/src/compile.rs +++ b/rust/src/compile.rs @@ -3,11 +3,7 @@ use log::info; use path_absolutize::Absolutize; use std::path::{Path, PathBuf}; -const MAKE: &str = if cfg!(target_os = "windows") { - "mingw32-make" -} else { - "make" -}; +const MAKE: &str = "make"; /// Compile a Stan Model. Requires a path to the BridgeStan sources (can be /// downloaded with [`download_bridgestan_src`](crate::download_bridgestan_src) if that feature diff --git a/src/bridgestan.cpp b/src/bridgestan.cpp index c4b3c47f..fb2ceecb 100644 --- a/src/bridgestan.cpp +++ b/src/bridgestan.cpp @@ -65,7 +65,7 @@ int bs_param_constrain(const bs_model* m, bool include_tp, bool include_gq, // If RNG is not provided (e.g., we are not using include_gq), use a dummy // RNG. // SAFETY: this can be static because we know the rng is never advanced. - static boost::ecuyer1988 dummy_rng(0); + static stan::rng_t dummy_rng(0); if (include_gq) throw std::invalid_argument("include_gq=true but rng=nullptr"); diff --git a/src/model_rng.cpp b/src/model_rng.cpp index 7f3cab56..2885d979 100644 --- a/src/model_rng.cpp +++ b/src/model_rng.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -219,7 +218,7 @@ void bs_model::param_unconstrain_json(const char* json, void bs_model::param_constrain(bool include_tp, bool include_gq, const double* theta_unc, double* theta, - boost::ecuyer1988& rng) const { + stan::rng_t& rng) const { Eigen::VectorXd params_unc = Eigen::VectorXd::Map(theta_unc, param_unc_num_); Eigen::VectorXd params; model_->write_array(rng, params_unc, params, include_tp, include_gq, diff --git a/src/model_rng.hpp b/src/model_rng.hpp index bc4ca87f..0330185c 100644 --- a/src/model_rng.hpp +++ b/src/model_rng.hpp @@ -2,7 +2,7 @@ #define MODEL_RNG_H #include -#include +#include #include #include #include @@ -31,6 +31,11 @@ class bs_model { */ ~bs_model() noexcept; + bs_model(bs_model const&) = delete; + bs_model(bs_model&&) = delete; + bs_model operator=(bs_model const&) = delete; + bs_model operator=(bs_model&&) = delete; + /** * Return the name of the model. This class manages the memory, * so the returned string should not be freed. @@ -116,7 +121,7 @@ class bs_model { */ void param_constrain(bool include_tp, bool include_gq, const double* theta_unc, double* theta, - boost::ecuyer1988& rng) const; + stan::rng_t& rng) const; /** * Calculate the log density for the specified unconstrain @@ -251,13 +256,9 @@ class bs_model { */ class bs_rng { public: - bs_rng(unsigned int seed) : rng_(seed) { - // discard first value as workaround for - // https://github.com/stan-dev/stan/issues/3167 - rng_.discard(1); - } + bs_rng(unsigned int seed) : rng_(0, 1, 0, seed) {} - boost::ecuyer1988 rng_; + stan::rng_t rng_; }; #endif diff --git a/stan b/stan index cc7c6177..9890ac0d 160000 --- a/stan +++ b/stan @@ -1 +1 @@ -Subproject commit cc7c61778af07eac9f30179379c6d78b58e015c3 +Subproject commit 9890ac0d3f944dcaabce702a8a189be311e2372b