Skip to content

Commit

Permalink
Update Stan to 2.35 (#235)
Browse files Browse the repository at this point in the history
* 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](stan-dev/stan@cc7c617...9890ac0)

---
updated-dependencies:
- dependency-name: stan
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* 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] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brian Ward <bward@flatironinstitute.org>
  • Loading branch information
dependabot[bot] and WardBrian authored Jun 7, 2024
1 parent 3a9870d commit 1bde73d
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 39 deletions.
13 changes: 3 additions & 10 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
workflow_dispatch: {}

env:
CACHE_VERSION: 1
CACHE_VERSION: 0

# only run one copy per PR
concurrency:
Expand Down Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion R/R/compile.R
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/

Expand Down
5 changes: 1 addition & 4 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion julia/src/compile.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

function get_make()
get(ENV, "MAKE", Sys.iswindows() ? "mingw32-make.exe" : "make")
get(ENV, "MAKE", "make")
end


Expand Down
5 changes: 1 addition & 4 deletions python/bridgestan/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions rust/src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/bridgestan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions src/model_rng.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <stan/io/empty_var_context.hpp>
#include <stan/io/var_context.hpp>
#include <stan/model/model_base.hpp>
#include <stan/services/util/create_rng.hpp>
#include <stan/math.hpp>
#include <stan/math/prim/meta.hpp>
#include <stan/version.hpp>
Expand Down Expand Up @@ -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,
Expand Down
17 changes: 9 additions & 8 deletions src/model_rng.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define MODEL_RNG_H

#include <stan/model/model_base.hpp>
#include <boost/random/additive_combine.hpp>
#include <stan/services/util/create_rng.hpp>
#include <string>
#include <vector>
#include <random>
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion stan
Submodule stan updated 116 files

0 comments on commit 1bde73d

Please sign in to comment.