Skip to content

Commit

Permalink
Merge branch 'master' into pr/839
Browse files Browse the repository at this point in the history
  • Loading branch information
jgabry committed Sep 13, 2023
2 parents f0812a1 + b29374e commit 7daf92b
Show file tree
Hide file tree
Showing 45 changed files with 306 additions and 328 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check-wsl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"

- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Install system dependencies
if: runner.os == 'Linux'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/Test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
token: ${{ secrets.GITHUB_TOKEN }}
workflow: Test-coverage.yml
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/[email protected]
- uses: r-lib/actions/[email protected]
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
NOT_CRAN: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: r-lib/actions/[email protected]
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cmdstan-tarball-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
NOT_CRAN: true

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install system dependencies
if: runner.os == 'Linux'
run: |
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: cmdstanr
Title: R Interface to 'CmdStan'
Version: 0.6.0.9000
Date: 2023-07-25
Version: 0.6.1.9000
Date: 2023-08-25
Authors@R:
c(person(given = "Jonah", family = "Gabry", role = c("aut", "cre"),
email = "[email protected]"),
Expand Down
17 changes: 15 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# cmdstanr 0.6.0.9000
# cmdstanr 0.6.1.9000

# cmdstanr 0.6.1

* Store return codes instead of always querying exit status by @jgabry in #798
* enable jacobian argument for optimization by @jgabry in #799
* Fix init_model_methods for models with no data by @andrjohns in #801
* Document a CmdStan-focused way to pre-compile Stan models in R packages by @wlandau in #809
* Describe how to efficiently save model fit objects by @wlandau in #816
* fix errors in doc for new methods by @jgabry in #823
* Give informative error when exposing stan functions with precompiled model by @andrjohns in #831
* Bugfixes in .stanfunctions, hessian model method, and exposing RNG functions by @andrjohns in #811
* Fix variable_skeleton() with containers by @andrjohns in #832
* Improve handling of user header by @martinmodrak in #818
* change duplicate stdout_file to stderr_file by @jgabry in #834

Items for next release

# cmdstanr 0.6.0

Expand Down
2 changes: 1 addition & 1 deletion R/example.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ print_example_program <-
#' stan_program <- "
#' data {
#' int<lower=0> N;
#' int<lower=0,upper=1> y[N];
#' array[N] int<lower=0,upper=1> y;
#' }
#' parameters {
#' real<lower=0,upper=1> theta;
Expand Down
4 changes: 2 additions & 2 deletions R/fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ CmdStanFit$set("public", name = "return_codes", value = return_codes)
#' mcmc_program <- write_stan_file(
#' 'data {
#' int<lower=0> N;
#' int<lower=0,upper=1> y[N];
#' array[N] int<lower=0,upper=1> y;
#' }
#' parameters {
#' real<lower=0,upper=1> theta;
Expand All @@ -1169,7 +1169,7 @@ CmdStanFit$set("public", name = "return_codes", value = return_codes)
#' }
#' }
#' generated quantities {
#' int y_rep[N];
#' array[N] int y_rep;
#' profile("gq") {
#' y_rep = bernoulli_rng(rep_vector(theta, N));
#' }
Expand Down
16 changes: 11 additions & 5 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ cmdstan_model <- function(stan_file = NULL, exe_file = NULL, compile = TRUE, ...
#' [`$save_hpp_file()`][model-method-compile] | Save the `.hpp` file containing the generated C++ code. |
#' [`$expose_functions()`][model-method-expose_functions] | Expose Stan functions for use in R. |
#'
#' ## Diagnostics
#'
#' |**Method**|**Description**|
#' |:----------|:---------------|
#' [`$diagnose()`][model-method-diagnose] | Run CmdStan's `"diagnose"` method to test gradients, return [`CmdStanDiagnose`] object. |
#'
#' ## Model fitting
#'
#' |**Method**|**Description**|
Expand Down Expand Up @@ -800,7 +806,7 @@ CmdStanModel$set("public", name = "variables", value = variables)
#' file <- write_stan_file("
#' data {
#' int N;
#' int y[N];
#' array[N] int y;
#' }
#' parameters {
#' // should have <lower=0> but omitting to demonstrate pedantic mode
Expand Down Expand Up @@ -926,7 +932,7 @@ CmdStanModel$set("public", name = "check_syntax", value = check_syntax)
#' file <- write_stan_file("
#' data {
#' int N;
#' int y[N];
#' array[N] int y;
#' }
#' parameters {
#' real lambda;
Expand Down Expand Up @@ -1653,7 +1659,7 @@ CmdStanModel$set("public", name = "variational", value = variational)
#' mcmc_program <- write_stan_file(
#' "data {
#' int<lower=0> N;
#' int<lower=0,upper=1> y[N];
#' array[N] int<lower=0,upper=1> y;
#' }
#' parameters {
#' real<lower=0,upper=1> theta;
Expand All @@ -1672,13 +1678,13 @@ CmdStanModel$set("public", name = "variational", value = variational)
#' gq_program <- write_stan_file(
#' "data {
#' int<lower=0> N;
#' int<lower=0,upper=1> y[N];
#' array[N] int<lower=0,upper=1> y;
#' }
#' parameters {
#' real<lower=0,upper=1> theta;
#' }
#' generated quantities {
#' int y_rep[N] = bernoulli_rng(rep_vector(theta, N));
#' array[N] int y_rep = bernoulli_rng(rep_vector(theta, N));
#' }"
#' )
#'
Expand Down
4 changes: 2 additions & 2 deletions R/run.R
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,8 @@ CmdStanRun$set("private", name = "run_variational_", value = .run_other)
if (file.exists(stdout_file)) {
cat(readLines(stdout_file), sep = "\n")
}
if (file.exists(stdout_file)) {
cat(readLines(stdout_file), sep = "\n")
if (file.exists(stderr_file)) {
cat(readLines(stderr_file), sep = "\n")
}
stop(
"Diagnose failed with the status code ", ret$status, "!\n",
Expand Down
19 changes: 17 additions & 2 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,20 @@ get_standalone_hpp <- function(stan_file, stancflags) {

get_function_name <- function(fun_start, fun_end, model_lines) {
fun_string <- paste(model_lines[(fun_start+1):fun_end], collapse = " ")
fun_name <- gsub("auto ", "", fun_string, fixed = TRUE)
types <- c(
"auto",
"int",
"double",
"Eigen::Matrix<(.*)>",
"std::vector<(.*)>"
)
pattern <- paste0(
# Only match if the type occurs at start of string
"^(\\s*)?(",
paste0(types, collapse="|"),
# Only match if type followed by a function name and opening bracket
")\\s*(?=\\w*\\()")
fun_name <- gsub(pattern, "", fun_string, perl = TRUE)
sub("\\(.*", "", fun_name, perl = TRUE)
}

Expand Down Expand Up @@ -869,7 +882,9 @@ get_plain_rtn <- function(fun_start, fun_end, model_lines) {
# that instantiates an RNG
prep_fun_cpp <- function(fun_start, fun_end, model_lines) {
fun_body <- paste(model_lines[fun_start:fun_end], collapse = " ")
fun_body <- gsub("auto", get_plain_rtn(fun_start, fun_end, model_lines), fun_body)
if (cmdstan_version() < "2.33") {
fun_body <- gsub("auto", get_plain_rtn(fun_start, fun_end, model_lines), fun_body)
}
fun_body <- gsub("// [[stan::function]]", "// [[Rcpp::export]]\n", fun_body, fixed = TRUE)
fun_body <- gsub("std::ostream\\*\\s*pstream__\\s*=\\s*nullptr", "", fun_body)
fun_body <- gsub("boost::ecuyer1988&\\s*base_rng__", "SEXP base_rng_ptr", fun_body)
Expand Down
1 change: 0 additions & 1 deletion _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ articles:
- cmdstanr-internals
- posterior
- r-markdown
- deprecations
- profiling
- articles-online-only/opencl

Expand Down
2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE-text.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/LICENSE.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 7daf92b

Please sign in to comment.