Skip to content

Commit 15679dd

Browse files
authored
Merge branch 'master' into use-air
2 parents 6ffc08b + 7e4f862 commit 15679dd

138 files changed

Lines changed: 5875 additions & 2303 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ jobs:
3333
fail-fast: false
3434
matrix:
3535
config:
36-
- {os: macOS-latest, r: 'devel', opencl: true}
36+
- {os: macOS-latest, r: 'devel', opencl: false}
3737
- {os: macOS-latest, r: 'release', opencl: true}
3838
- {os: macos-26, r: 'release', opencl: false}
3939
- {os: macos-15-intel, r: 'release', opencl: false}
40-
- {os: windows-latest, r: 'devel' }
41-
- {os: windows-latest, r: 'release'}
42-
- {os: windows-2022, r: '4.1'}
43-
- {os: windows-latest, r: 'oldrel'}
44-
- {os: ubuntu-latest, r: 'devel', opencl: true}
40+
- {os: windows-latest, r: 'devel', opencl: false}
41+
- {os: windows-latest, r: 'release', opencl: false}
42+
- {os: windows-2022, r: '4.1', opencl: false}
43+
- {os: windows-latest, r: 'oldrel', opencl: false}
44+
- {os: ubuntu-latest, r: 'devel', opencl: false}
4545
- {os: ubuntu-latest, r: 'release', opencl: true}
46-
- {os: ubuntu-latest, r: 'oldrel', opencl: true}
46+
- {os: ubuntu-latest, r: 'oldrel', opencl: false}
47+
- {os: windows-11-arm, r: 'release', opencl: false}
4748
env:
4849
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
4950
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
@@ -75,38 +76,51 @@ jobs:
7576
- uses: r-lib/actions/setup-r-dependencies@v2
7677
with:
7778
cache: "always"
78-
extra-packages: any::rcmdcheck, local::.
79+
extra-packages: any::rcmdcheck, local::., ${{ matrix.config.r == '4.1' && 'qs2=?ignore' || '' }}
7980

80-
- name: Debug Windows toolchain resolution
81-
if: ${{ runner.os == 'Windows' }}
81+
- name: Test Windows toolchain in directory with spaces
82+
if: ${{ runner.os == 'Windows' && matrix.config.r == '4.1' }}
8283
run: |
83-
rtools_home <- cmdstanr:::rtools4x_home_path()
84-
candidates <- cmdstanr:::rtools4x_toolchain_candidates()
85-
selected <- cmdstanr:::rtools4x_toolchain_path()
86-
cat("R version: ", as.character(getRversion()), "\n", sep = "")
87-
cat("Rtools home: ", rtools_home, "\n", sep = "")
88-
cat("Toolchain candidates:\n")
89-
if (length(candidates) == 0) {
90-
cat(" - <none>\n")
91-
} else {
92-
cat(paste0(" - ", candidates), sep = "\n")
93-
cat("\n")
84+
New-Item -ItemType Directory -Path "C:\tmp path with spaces" -Force
85+
Move-Item -Path "C:\rtools40" -Destination "C:\tmp path with spaces\"
86+
echo "RTOOLS40_HOME=C:/tmp path with spaces/rtools40" >> $env:GITHUB_ENV
87+
shell: pwsh
88+
89+
- name: Verify R_TOOLS_SOFT configuration
90+
if: ${{ matrix.config.os == 'windows-latest' && matrix.config.r != '4.1' }}
91+
run: |
92+
rtools_soft <- suppressWarnings(
93+
tools::Rcmd(c("config", "R_TOOLS_SOFT"), stdout = TRUE)
94+
)
95+
if (
96+
!is.null(attr(rtools_soft, "status")) ||
97+
length(rtools_soft) != 1L ||
98+
!nzchar(trimws(rtools_soft))
99+
) {
100+
stop("R CMD config R_TOOLS_SOFT did not return a valid path.")
94101
}
95-
cat("Selected toolchain: ", selected, "\n", sep = "")
96-
selected_ok <- cmdstanr:::is_rtools4x_toolchain_usable(selected)
97-
if (!selected_ok) {
98-
stop("Resolved Windows toolchain path is not usable.")
102+
rtools_soft <- trimws(rtools_soft)
103+
required <- c(
104+
file.path(dirname(rtools_soft), "usr", "bin", "make.exe"),
105+
file.path(rtools_soft, "bin", "c++.exe")
106+
)
107+
missing <- required[!file.exists(required)]
108+
if (length(missing)) {
109+
stop(
110+
"R_TOOLS_SOFT is configured, but expected executables are missing: ",
111+
paste(missing, collapse = ", ")
112+
)
99113
}
100114
shell: Rscript {0}
101115

102116
- name: Install POCL on Ubuntu Runners
103-
if: ${{ matrix.config.os == 'ubuntu-latest' }}
117+
if: ${{ matrix.config.os == 'ubuntu-latest' && matrix.config.opencl }}
104118
run: |
105119
sudo apt-get update && sudo apt-get install -y ocl-icd-opencl-dev pocl-opencl-icd
106120
shell: bash
107121

108122
- name: Install POCL on MacOS Runners
109-
if: ${{ matrix.config.os == 'macOS-latest' }}
123+
if: ${{ matrix.config.os == 'macOS-latest' && matrix.config.opencl }}
110124
run: |
111125
brew install pocl
112126
# Set LDLIBS_OPENCL environment variable so that CPU OpenCL is found
@@ -139,6 +153,7 @@ jobs:
139153
- uses: r-lib/actions/check-r-package@v2
140154
env:
141155
_R_CHECK_CRAN_INCOMING_: false
156+
_R_CHECK_FORCE_SUGGESTS_: ${{ matrix.config.r == '4.1' && 'false' || 'true' }}
142157

143158
- name: Show testthat output
144159
if: always()

.github/workflows/pkgdown.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434

3535
- uses: r-lib/actions/setup-r-dependencies@v2
3636
with:
37-
extra-packages: any::pkgdown, local::., stan-dev/pkgdown-config
37+
extra-packages: any::pkgdown, local::., stan-dev/pkgdown-config, qs2=?source, stringfish=?source
3838

3939
- name: Install CmdStan
4040
run: Rscript -e "cmdstanr::install_cmdstan()"
@@ -53,4 +53,4 @@ jobs:
5353
with:
5454
clean: false
5555
branch: gh-pages
56-
folder: docs
56+
folder: docs

DESCRIPTION

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: cmdstanr
22
Title: R Interface to 'CmdStan'
3-
Version: 0.9.0.9000
3+
Version: 0.9.0.9002
44
Date: 2025-03-30
55
Authors@R:
66
c(person(given = "Jonah", family = "Gabry", role = c("aut", "cre"),
@@ -40,11 +40,12 @@ Depends:
4040
R (>= 4.0.0)
4141
Imports:
4242
checkmate,
43-
data.table,
43+
data.table (>= 1.11.6),
4444
jsonlite (>= 1.8.7),
4545
posterior (>= 1.5.0),
4646
processx (>= 3.5.0),
4747
R6 (>= 2.4.0),
48+
vctrs,
4849
withr (>= 2.5.0),
4950
rlang (>= 0.4.7)
5051
Suggests:

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ export(write_stan_file)
4646
export(write_stan_json)
4747
import(R6)
4848
importFrom(posterior,as_draws)
49-
importFrom(stats,aggregate)

NEWS.md

Lines changed: 75 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,93 @@
11
# cmdstanr (development version)
22

3+
* Chain IDs in generated filenames are now zero-padded to at least two digits,
4+
for example `01` instead of `1`. (#1244)
5+
* When using CmdStan through WSL, paths for output, diagnostic, profile, config,
6+
and metric files now remain accessible to Windows R when an explicit output
7+
directory is supplied. (#1110; related: #1113)
8+
* Lists of matrices/vectors and data frames can now be supplied for variables
9+
declared as `int` in the Stan program. Previously these worked only for `real`
10+
variables and errored for `int` ones. (#817)
11+
* Data frame columns that are not numeric, integer, logical, or
12+
factor are now an error. Previously `data.matrix()` silently coerced them, so a
13+
character column reached Stan as alphabetically ordered integer codes. Convert
14+
the column explicitly, e.g. with `as.integer()`, if integer codes are what you
15+
want. (#1225)
16+
* Lists of logical vectors/matrices are now converted to integers like logical
17+
variables are, instead of erroring. (#1225)
18+
* Supplying a factor for a variable not declared as `int` is now an error. (#1225)
19+
* Factors are now accepted for length-1 `int` arrays (e.g. `array[1] int x`),
20+
which previously errored. (#1225)
21+
* The `CMDSTANR_NO_VER_CHECK` R option and environment variable are deprecated
22+
as of CmdStanR 1.0.0; use the lowercase `cmdstanr_no_ver_check` forms instead.
23+
* `check_cmdstan_toolchain()` now locates Windows toolchains using `R_TOOLS_SOFT` and falls back to `PATH`, improving support for alternate R distributions and future Rtools releases. (#1211)
24+
* `$compile()` now works with named `stanc_options` values such as
25+
`canonicalize`. The values were shell-quoted for Make and the same quoted
26+
strings were also passed to `stanc` directly, which rejected them. (#1227)
27+
* `$compile()` now enables `allow-undefined` for user headers supplied through
28+
`cpp_options`, not just through the `user_header` argument. (#1227)
29+
* `stanc` failures during `$compile()` are now reported immediately, with the
30+
`stanc` error message. Previously they surfaced several steps later. (#1227)
31+
* Errors for include paths that do not exist now report the resolved absolute
32+
path. (#1227)
33+
* Numeric `stanc_options` values such as `list("max-line-length" = 78)` are no
34+
longer dropped. (#1233)
35+
* CmdStanModel methods now correctly handle `#include` directories with spaces
36+
in their paths. (#820)
37+
* `$include_paths()` now returns absolute paths, and relative include paths are
38+
resolved when the model object is created or `$compile()` is called rather than
39+
on each `stanc` call. Previously a model created from a relative path could
40+
resolve `#include` directives against the wrong directory if the working
41+
directory changed. (#1229)
42+
* `$cpp_options()` no longer includes a `STAN_VERSION` entry read from the model
43+
executable's metadata. It was never a C++ option; use `$cmdstan_version()` instead. (#1215)
44+
* CmdStanModel methods now use executable metadata regardless of the
45+
capitalization of C++ option names. Any executable reporting threading enabled
46+
requires the corresponding `threads` or `threads_per_chain` argument. (#765, #1100)
47+
* Pathfinder fits used as initial values now use uniform weights when CmdStan
48+
already PSIS-resampled their draws, avoiding a second application of importance weights. (#1206)
49+
* Pathfinder fits used as initial values now correctly treat draws with different
50+
initialization parameter values as distinct even when their log weights are equal,
51+
and collapse duplicate resampled draws while retaining their selection frequency. (#1207)
52+
* `pathfinder()` now passes separately supplied initial values to every path
53+
instead of using only the first path's initial values. (#1206)
354
* `pathfinder()` now respects `save_single_paths = TRUE` instead of always
455
passing `0` to CmdStan.
556
* `pathfinder()` now uses `threads` argument (`num_threads` is deprecated),
657
to be consistent with other methods.
58+
* The `num_paths` documentation for `pathfinder()` now notes that running
59+
multiple paths in parallel requires compiling with
60+
`cpp_options = list(stan_threads = TRUE)` and setting `threads`. (#896)
61+
* The `save_latent_dynamics` argument is now limited to `$sample()`,
62+
`$sample_mpi()`, and `$variational()`, matching the CmdStan algorithms
63+
that support diagnostic CSV output.
764
* Informative error when exposing functions using names that are reserved
865
keywords (@VisruthSK, #1154)
9-
* `save_cmdstan_config` and `save_metric` default to `FALSE` but can be
66+
* `save_cmdstan_config` and `save_metric` default to `FALSE` but can be
1067
set to `TRUE` for an entire R session via new global options. (#1159)
11-
* `cmdstan_model()` no longer fails when `MAKEFLAGS` enables directory-printing
68+
* The compilation spinner can now be disabled for an entire R session by setting
69+
the new `cmdstanr_spinner` global option to `FALSE`. The spinner shown while
70+
installing or rebuilding CmdStan and while checking syntax also respects this
71+
option, and is no longer shown when knitting. (#486)
72+
* `save_metric_files()` now gives an informative error when metric files were
73+
not created and keeps saved metric files after the fitted model is garbage-collected. (#1021)
74+
* `cmdstan_model()` no longer fails when `MAKEFLAGS` enables directory-printing
1275
output while reading `STANCFLAGS` from `make`. (#1163)
76+
* `cmdstan_model()` now retains include paths when initialized with both a Stan file
77+
and a precompiled executable (#1094).
78+
* `$generate_quantities()` now also accepts `CmdStanMLE`, `CmdStanLaplace`,
79+
and `CmdStanPathfinder` fitted model objects as `fitted_params`. (#1203)
80+
* `$generate_quantities()` now reports per-process execution times with
81+
CmdStan 2.39 or newer, and `read_cmdstan_csv()` returns these times from
82+
standalone generated quantities CSV files. (#1168)
1383
* `laplace()` no longer overwrites the internally generated optimizer CSV when
1484
`mode = NULL` and `output_basename` is supplied. The internally generated
15-
optimizer CSV now uses the filename `<output_basename>-mode-1.csv`.
85+
optimizer CSV now uses the filename `<output_basename>-mode-01.csv`.
1686

1787
* CmdStanModel objects created using `compile_model_methods = TRUE` that are
1888
then saved and reloaded no longer error in model fitting methods. Model methods
1989
are recompiled lazily if needed. (#1158)
20-
90+
2191
* CmdStan versions older than 2.35.0 are no longer supported. (#1144)
2292
* Minimum R version increased to 4.0.0. (#1144)
2393
* Removed legacy Windows toolchain paths for older CmdStan releases. (#1144)
@@ -41,7 +111,7 @@ are recompiled lazily if needed. (#1158)
41111
- `save_extra_diagnostics` (`save_latent_dynamics`)
42112
- `max_depth` (`max_treedepth`)
43113
- `stepsize` (`step_size`)
44-
114+
45115

46116
# cmdstanr 0.9.0
47117

0 commit comments

Comments
 (0)