Skip to content

Commit b475e9e

Browse files
committed
Merge branch 'master' into windows-fixes
2 parents 79374bc + 044f3dd commit b475e9e

13 files changed

Lines changed: 64 additions & 32 deletions

.github/dependabot.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
token: ${{ secrets.GITHUB_TOKEN }}
4848
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
4949

50-
- uses: actions/checkout@v2
50+
- uses: actions/checkout@v3
5151

5252
- name: Install system dependencies
5353
if: runner.os == 'Linux'
@@ -78,7 +78,7 @@ jobs:
7878

7979
- name: Cache R packages
8080
if: runner.os != 'Windows'
81-
uses: actions/cache@v2
81+
uses: actions/cache@v3
8282
with:
8383
path: ${{ env.R_LIBS_USER }}
8484
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
@@ -119,7 +119,7 @@ jobs:
119119

120120
- name: Upload check results
121121
if: failure()
122-
uses: actions/upload-artifact@v2
122+
uses: actions/upload-artifact@v3
123123
with:
124124
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
125125
path: check

.github/workflows/Test-coverage.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
token: ${{ secrets.GITHUB_TOKEN }}
3333
workflow: Test-coverage.yml
3434
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'"
35-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@v3
3636

3737
- uses: r-lib/actions/setup-r@v2
3838
- uses: r-lib/actions/setup-pandoc@v1
@@ -50,7 +50,7 @@ jobs:
5050
shell: Rscript {0}
5151

5252
- name: Cache R packages
53-
uses: actions/cache@v2
53+
uses: actions/cache@v3
5454
with:
5555
path: ${{ env.R_LIBS_USER }}
5656
key: ubuntu-r-4.0-1-${{ hashFiles('.github/depends.Rds') }}
@@ -83,7 +83,7 @@ jobs:
8383
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
8484
NOT_CRAN: true
8585
steps:
86-
- uses: actions/checkout@v2
86+
- uses: actions/checkout@v3
8787

8888
- uses: r-lib/actions/setup-r@v2
8989
with:

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
NOT_CRAN: true
3333

3434
steps:
35-
- uses: actions/checkout@v2
35+
- uses: actions/checkout@v3
3636

3737
- name: Set path for RTools 4.0
3838
if: runner.os == 'Windows'
@@ -76,7 +76,7 @@ jobs:
7676

7777
- name: Cache R packages
7878
if: runner.os != 'Windows'
79-
uses: actions/cache@v2
79+
uses: actions/cache@v3
8080
with:
8181
path: ${{ env.R_LIBS_USER }}
8282
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
@@ -115,7 +115,7 @@ jobs:
115115

116116
- name: Upload check results
117117
if: failure()
118-
uses: actions/upload-artifact@v2
118+
uses: actions/upload-artifact@v3
119119
with:
120120
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
121121
path: check

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: cmdstanr
22
Title: R Interface to 'CmdStan'
3-
Version: 0.5.2
3+
Version: 0.5.2.1
44
Date: 2022-04-24
55
Authors@R:
66
c(person(given = "Jonah", family = "Gabry", role = c("aut", "cre"),

NEWS.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
# cmdstanr 0.4.0.9000
2+
3+
### Bug fixes
4+
5+
* In `cmdstan_default_path()` we now ignore directories inside `.cmdstan` that don't start
6+
with `"cmdstan-"`. (#651)
7+
8+
* Fixed Windows issue related to not locating `grep.exe` or when it is located in a path
9+
with spaces. (@weshinsley, #661, #663)
10+
11+
* Fixed a bug with diagnostic checks when ebfmi is NaN.
12+
13+
* Fixed a bug that caused issues when using `~` or `.` in paths supplied to the
14+
`cmdstanr_write_stan_file_dir` global option.
15+
116
# cmdstanr 0.5.2
217

318
* Refactored toolchain installation and checks for R 4.x on Windows and added support

R/csv.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@ read_cmdstan_csv <- function(files,
236236
grep_path_quotes <- paste0('"', grep_path_repaired, '"')
237237
fread_cmd <- paste0(
238238
grep_path_quotes,
239-
" '^[#a-zA-Z]' --color=never '",
239+
" -v \"^#\" --color=never \"",
240240
output_file,
241-
"'"
241+
"\""
242242
)
243243
} else {
244244
fread_cmd <- paste0("grep -v '^#' --color=never '", output_file, "'")
@@ -578,9 +578,9 @@ read_csv_metadata <- function(csv_file) {
578578
grep_path_quotes <- paste0('"', grep_path_repaired, '"')
579579
fread_cmd <- paste0(
580580
grep_path_quotes,
581-
" '^[#a-zA-Z]' --color=never '",
581+
" \"^[#a-zA-Z]\" --color=never \"",
582582
csv_file,
583-
"'"
583+
"\""
584584
)
585585
} else {
586586
fread_cmd <- paste0("grep '^[#a-zA-Z]' --color=never '", csv_file, "'")

R/example.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ write_stan_file <- function(code,
148148
basename = NULL,
149149
force_overwrite = FALSE,
150150
hash_salt = "") {
151+
dir <- absolute_path(dir)
151152
if (!dir.exists(dir)) {
152153
dir.create(dir, recursive = TRUE)
153154
}

R/install.R

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
509509
stop(
510510
"\n", rtools_version, " was not found but is required to run CmdStan with R version ",
511511
R.version$major, ".", R.version$minor, ".",
512-
"\nPlease install ", rtools_version, " and run check_cmdstan_toolchain().",
512+
"\nPlease install ", rtools_version, " and run cmdstanr::check_cmdstan_toolchain().",
513513
call. = FALSE
514514
)
515515
}
@@ -518,7 +518,7 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
518518
if (grepl("\\(|)| ", rtools_path)) {
519519
stop(
520520
"\n", rtools_version, " is installed in a path with spaces or brackets, which is not supported.",
521-
"\nPlease reinstall ", rtools_version, " to a valid path, restart R, and then run check_cmdstan_toolchain().",
521+
"\nPlease reinstall ", rtools_version, " to a valid path, restart R, and then run cmdstanr::check_cmdstan_toolchain().",
522522
call. = FALSE
523523
)
524524
}
@@ -527,7 +527,7 @@ check_rtools4x_windows_toolchain <- function(fix = FALSE, quiet = FALSE) {
527527
if (!fix) {
528528
stop(
529529
"\n", rtools_version, " installation found but the toolchain was not installed.",
530-
"\nRun check_cmdstan_toolchain(fix = TRUE) to fix the issue.",
530+
"\nRun cmdstanr::check_cmdstan_toolchain(fix = TRUE) to fix the issue.",
531531
call. = FALSE
532532
)
533533
} else {
@@ -615,13 +615,13 @@ check_unix_make <- function() {
615615
"The 'make' tool was not found. ",
616616
"Please install the command line tools for Mac with 'xcode-select --install' ",
617617
"or install Xcode from the app store. ",
618-
"Then restart R and run check_cmdstan_toolchain().",
618+
"Then restart R and run cmdstanr::check_cmdstan_toolchain().",
619619
call. = FALSE
620620
)
621621
} else {
622622
stop(
623623
"The 'make' tool was not found. ",
624-
"Please install 'make', restart R, and then run check_cmdstan_toolchain().",
624+
"Please install 'make', restart R, and then run cmdstanr::check_cmdstan_toolchain().",
625625
call. = FALSE
626626
)
627627
}
@@ -638,14 +638,14 @@ check_unix_cpp_compiler <- function() {
638638
"A suitable C++ compiler was not found. ",
639639
"Please install the command line tools for Mac with 'xcode-select --install' ",
640640
"or install Xcode from the app store. ",
641-
"Then restart R and run check_cmdstan_toolchain().",
641+
"Then restart R and run cmdstanr::check_cmdstan_toolchain().",
642642
call. = FALSE
643643
)
644644
} else {
645645
stop(
646646
"A C++ compiler was not found. ",
647647
"Please install the 'clang++' or 'g++' compiler, restart R, ",
648-
"and run check_cmdstan_toolchain().",
648+
"and run cmdstanr::check_cmdstan_toolchain().",
649649
call. = FALSE
650650
)
651651
}

R/utils.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,17 @@ ebfmi <- function(post_warmup_sampler_diagnostics) {
308308

309309
check_ebfmi <- function(post_warmup_sampler_diagnostics, threshold = 0.2) {
310310
efbmi_per_chain <- ebfmi(post_warmup_sampler_diagnostics)
311-
if (any(efbmi_per_chain < threshold)) {
311+
nan_efbmi_count <- sum(is.nan(efbmi_per_chain))
312+
efbmi_below_threshold <- sum(efbmi_per_chain < threshold)
313+
if (nan_efbmi_count > 0) {
312314
message(
313-
"Warning: ", sum(efbmi_per_chain < threshold), " of ", length(efbmi_per_chain),
315+
"Warning: ", nan_efbmi_count, " of ", length(efbmi_per_chain),
316+
" chains have a NaN E-BFMI.\n",
317+
"See https://mc-stan.org/misc/warnings for details.\n"
318+
)
319+
} else if (efbmi_below_threshold > 0) {
320+
message(
321+
"Warning: ", efbmi_below_threshold, " of ", length(efbmi_per_chain),
314322
" chains had an E-BFMI less than ", threshold, ".\n",
315323
"See https://mc-stan.org/misc/warnings for details.\n"
316324
)

0 commit comments

Comments
 (0)