Skip to content

Commit 019a4ee

Browse files
authored
Merge branch 'master' into master
2 parents dc0b45f + d15d028 commit 019a4ee

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ Suggests:
5555
rmarkdown (>= 1.0.0),
5656
rstan (>= 2.17.1),
5757
rstanarm (>= 2.17.4),
58-
rstantools (>= 1.5.0),
58+
rstantools (>= 2.0.0),
5959
scales,
6060
shinystan (>= 2.3.0),
6161
survival,

NEWS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# bayesplot (development version)
22

3+
34
* New `show_marginal` argument to `ppd_*()` functions to show the PPD - the marginal predictive distribution by @mattansb (#425)
5+
* Added unit tests for previously untested edge cases in `param_range()`, `param_glue()`, and `tidyselect_parameters()` (no-match, partial-match, and negation behavior).
6+
* Bumped minimum version for `rstantools` from `>= 1.5.0` to `>= 2.0.0` .
47
* Use `rlang::warn()` and `rlang::inform()` for selected PPC user messages instead of base `warning()` and `message()`.
58
* Standardize input validation errors in `ppc_km_overlay()` and interpolation helpers to use `rlang::abort()` for consistent error handling.
69
* Fix assignment-in-call bug in `mcmc_rank_ecdf()` (#).

tests/testthat/test-tidy-params.R

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
source(test_path("data-for-mcmc-tests.R"))
2+
3+
# param_range --------------------------------------------------------------
4+
5+
test_that("param_range returns empty integer when no matches", {
6+
all_pars <- c("alpha", "gamma[1]", "gamma[2]")
7+
result <- param_range("beta", 1:3, vars = all_pars)
8+
expect_identical(result, integer(0))
9+
})
10+
11+
test_that("param_range drops non-matching indices silently", {
12+
all_pars <- c("alpha", "beta[1]", "beta[3]")
13+
# beta[2] does not exist, should be silently dropped
14+
result <- param_range("beta", 1:3, vars = all_pars)
15+
expect_equal(result, c(2L, 3L))
16+
})
17+
18+
# param_glue ---------------------------------------------------------------
19+
20+
test_that("param_glue returns empty integer when no matches", {
21+
all_pars <- c("alpha", "sigma")
22+
result <- param_glue("beta[{i}]", i = 1:3, vars = all_pars)
23+
expect_identical(result, integer(0))
24+
})
25+
26+
test_that("param_glue drops non-matching names silently", {
27+
all_pars <- c("b[X:1]", "b[Y:2]", "sigma")
28+
# b[X:2] and b[Y:1] don't exist
29+
result <- param_glue("b[{var}:{lev}]", var = c("X", "Y"), lev = c(1, 2),
30+
vars = all_pars)
31+
expect_equal(result, c(1L, 2L))
32+
})
33+
34+
# tidyselect_parameters ----------------------------------------------------
35+
36+
test_that("tidyselect_parameters works with negation", {
37+
all_pars <- c("alpha", "beta[1]", "beta[2]", "sigma")
38+
selected <- tidyselect_parameters(all_pars, vars(-alpha))
39+
expect_equal(selected, c("beta[1]", "beta[2]", "sigma"))
40+
})

0 commit comments

Comments
 (0)