Skip to content

Commit 6b47912

Browse files
committed
Merge branch 'master' into pr/932
2 parents 513d09e + 4a865bb commit 6b47912

33 files changed

Lines changed: 394 additions & 96 deletions

.github/workflows/R-CMD-check-wsl.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,8 @@ jobs:
3737

3838
- uses: actions/checkout@v4
3939

40-
- uses: r-lib/actions/setup-r@v2.7.2
41-
with:
42-
r-version: 'release'
43-
rtools-version: '42'
44-
- uses: r-lib/actions/setup-pandoc@v2.7.2
40+
- uses: r-lib/actions/setup-r@v2.8.7
41+
- uses: r-lib/actions/setup-pandoc@v2.8.7
4542

4643
- name: Query dependencies
4744
run: |
@@ -58,7 +55,7 @@ jobs:
5855
install.packages("curl")
5956
shell: Rscript {0}
6057

61-
- uses: Vampire/setup-wsl@v2
58+
- uses: Vampire/setup-wsl@v3
6259
with:
6360
distribution: Ubuntu-22.04
6461
use-cache: 'false'

.github/workflows/R-CMD-check.yaml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ jobs:
3131
- {os: ubuntu-20.04, r: 'devel', rtools: ''}
3232
- {os: ubuntu-20.04, r: 'release', rtools: ''}
3333
- {os: ubuntu-20.04, r: 'oldrel', rtools: ''}
34-
- {os: ubuntu-20.04, r: '3.6', rtools: ''}
3534
env:
3635
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
3736
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -57,11 +56,11 @@ jobs:
5756
sudo apt-get install -y libcurl4-openssl-dev || true
5857
sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev || true
5958
60-
- uses: r-lib/actions/setup-r@v2.7.2
59+
- uses: r-lib/actions/setup-r@v2.8.7
6160
with:
6261
r-version: ${{ matrix.config.r }}
6362
rtools-version: ${{ matrix.config.rtools }}
64-
- uses: r-lib/actions/setup-pandoc@v2.7.2
63+
- uses: r-lib/actions/setup-pandoc@v2.8.7
6564

6665
- name: Query dependencies
6766
run: |

.github/workflows/Test-coverage.yaml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ jobs:
3434
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
3535
- uses: actions/checkout@v4
3636

37-
- uses: r-lib/actions/setup-r@v2.7.2
38-
- uses: r-lib/actions/setup-pandoc@v2.7.2
37+
- uses: r-lib/actions/setup-r@v2.8.7
38+
- uses: r-lib/actions/setup-pandoc@v2.8.7
3939

4040
- name: Install Ubuntu dependencies
4141
run: |
@@ -85,12 +85,9 @@ jobs:
8585
steps:
8686
- uses: actions/checkout@v4
8787

88-
- uses: r-lib/actions/setup-r@v2.7.2
89-
with:
90-
r-version: 'release'
91-
rtools-version: '42'
88+
- uses: r-lib/actions/setup-r@v2.8.7
9289

93-
- uses: r-lib/actions/setup-pandoc@v2.7.2
90+
- uses: r-lib/actions/setup-pandoc@v2.8.7
9491

9592
- name: Query dependencies
9693
run: |

.github/workflows/cmdstan-tarball-check.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ jobs:
4040
sudo apt-get install -y libcurl4-openssl-dev || true
4141
sudo apt-get install -y openmpi-bin openmpi-common libopenmpi-dev || true
4242
43-
- uses: r-lib/actions/setup-r@v2.7.2
43+
- uses: r-lib/actions/setup-r@v2.8.7
4444
with:
4545
r-version: ${{ matrix.config.r }}
4646
rtools-version: ${{ matrix.config.rtools }}
4747

48-
- uses: r-lib/actions/setup-pandoc@v2.7.2
48+
- uses: r-lib/actions/setup-pandoc@v2.8.7
4949

5050
- name: Query dependencies
5151
run: |

DESCRIPTION

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ Title: R Interface to 'CmdStan'
33
Version: 0.7.1
44
Date: 2024-01-09
55
Authors@R:
6-
c(person(given = "Jonah", family = "Gabry", role = c("aut", "cre"),
7-
email = "jsg2201@columbia.edu"),
6+
c(person(given = "Jonah", family = "Gabry", role = "aut",
7+
email = "jsg2201@columbia.edu"),
88
person(given = "Rok", family = "Češnovar", role = "aut",
9-
email = "rok.cesnovar@fri.uni-lj.si"),
10-
person(given = "Andrew", family = "Johnson", role = "aut",
11-
comment = c(ORCID = "0000-0001-7000-8065")),
9+
email = "rok.cesnovar@fri.uni-lj.si"),
10+
person(given = "Andrew", family = "Johnson", role = c("aut", "cre"),
11+
email = "andrew.johnson@arjohnsonau.com",
12+
comment = c(ORCID = "0000-0001-7000-8065")),
1213
person(given = "Ben", family = "Bales", role = "ctb"),
1314
person(given = "Mitzi", family = "Morris", role = "ctb"),
1415
person(given = "Mikhail", family = "Popov", role = "ctb"),
@@ -33,7 +34,7 @@ RoxygenNote: 7.3.1
3334
Roxygen: list(markdown = TRUE, r6 = FALSE)
3435
SystemRequirements: CmdStan (https://mc-stan.org/users/interfaces/cmdstan)
3536
Depends:
36-
R (>= 3.5.0)
37+
R (>= 4.0.0)
3738
Imports:
3839
checkmate,
3940
data.table,

NAMESPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ S3method(as_draws,CmdStanMCMC)
66
S3method(as_draws,CmdStanMLE)
77
S3method(as_draws,CmdStanPathfinder)
88
S3method(as_draws,CmdStanVB)
9+
export(as.CmdStanDiagnose)
10+
export(as.CmdStanGQ)
11+
export(as.CmdStanLaplace)
12+
export(as.CmdStanMCMC)
13+
export(as.CmdStanMLE)
14+
export(as.CmdStanPathfinder)
15+
export(as.CmdStanVB)
916
export(as_cmdstan_fit)
1017
export(as_draws)
1118
export(as_mcmc.list)

R/args.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,9 @@ SampleArgs <- R6::R6Class(
266266
fileext = ".json"
267267
)
268268
for (i in seq_along(inv_metric_paths)) {
269+
if (length(inv_metric[[i]]) == 1 && metric == "diag_e") {
270+
inv_metric[[i]] <- array(inv_metric[[i]], dim = c(1))
271+
}
269272
write_stan_json(list(inv_metric = inv_metric[[i]]), inv_metric_paths[i])
270273
}
271274

R/cmdstanr-package.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#' [_Getting started with CmdStanR_](https://mc-stan.org/cmdstanr/articles/cmdstanr.html)
2727
#' demonstrates the basic functionality of the package.
2828
#'
29+
#' For a list of global [options][base::options()] see
30+
#' [cmdstanr_global_options].
31+
#'
2932
#' @template seealso-docs
3033
#' @inherit cmdstan_model examples
3134
#' @import R6

R/fit.R

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1784,7 +1784,10 @@ inv_metric <- function(matrix = TRUE) {
17841784
out <- private$inv_metric_
17851785
if (matrix && !is.matrix(out[[1]])) {
17861786
# convert each vector to a diagonal matrix
1787-
out <- lapply(out, diag)
1787+
out <- lapply(out, function(x) diag(x, nrow = length(x)))
1788+
} else if (length(out[[1]]) == 1) {
1789+
# convert each scalar to an array with dimension 1
1790+
out <- lapply(out, array, dim = c(1))
17881791
}
17891792
out
17901793
}

R/generics.R

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#' Coercion methods for CmdStan objects
2+
#'
3+
#' These are generic functions intended to primarily be used by developers of
4+
#' packages that interface with on CmdStanR. Developers can define methods on
5+
#' top of these generics to coerce objects into CmdStanR's fitted model objects.
6+
#'
7+
#' @param object to be coerced
8+
#' @param ... additional arguments
9+
#'
10+
#' @name cmdstan_coercion
11+
NULL
12+
13+
#' @rdname cmdstan_coercion
14+
#' @export
15+
as.CmdStanMCMC <- function(object, ...) {
16+
UseMethod("as.CmdStanMCMC")
17+
}
18+
19+
#' @rdname cmdstan_coercion
20+
#' @export
21+
as.CmdStanMLE <- function(object, ...) {
22+
UseMethod("as.CmdStanMLE")
23+
}
24+
25+
#' @rdname cmdstan_coercion
26+
#' @export
27+
as.CmdStanLaplace <- function(object, ...) {
28+
UseMethod("as.CmdStanLaplace")
29+
}
30+
31+
#' @rdname cmdstan_coercion
32+
#' @export
33+
as.CmdStanVB <- function(object, ...) {
34+
UseMethod("as.CmdStanVB")
35+
}
36+
37+
#' @rdname cmdstan_coercion
38+
#' @export
39+
as.CmdStanPathfinder <- function(object, ...) {
40+
UseMethod("as.CmdStanPathfinder")
41+
}
42+
43+
#' @rdname cmdstan_coercion
44+
#' @export
45+
as.CmdStanGQ <- function(object, ...) {
46+
UseMethod("as.CmdStanGQ")
47+
}
48+
49+
#' @rdname cmdstan_coercion
50+
#' @export
51+
as.CmdStanDiagnose <- function(object, ...) {
52+
UseMethod("as.CmdStanDiagnose")
53+
}

0 commit comments

Comments
 (0)