Skip to content

Commit

Permalink
warn of behaviour change
Browse files Browse the repository at this point in the history
  • Loading branch information
sbfnk committed Oct 10, 2023
1 parent 47ccb4f commit 928ce19
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ importFrom(purrr,transpose)
importFrom(purrr,walk)
importFrom(rlang,abort)
importFrom(rlang,cnd_muffle)
importFrom(rlang,warn)
importFrom(rstan,expose_stan_functions)
importFrom(rstan,extract)
importFrom(rstan,sampling)
Expand Down
13 changes: 13 additions & 0 deletions R/dist.R
Original file line number Diff line number Diff line change
Expand Up @@ -892,6 +892,7 @@ tune_inv_gamma <- function(lower = 2, upper = 21) {
#'
#' @author Sebastian Funk
#' @author Sam Abbott
#' @importFrom rlang warn
#' @export
#' @examples
#' # A fixed lognormal distribution with mean 5 and sd 1.
Expand All @@ -905,6 +906,18 @@ tune_inv_gamma <- function(lower = 2, upper = 21) {
dist_spec <- function(mean, sd = 0, mean_sd = 0, sd_sd = 0,
distribution = c("lognormal", "gamma"), max,
pmf = numeric(0), fixed = FALSE) {
## deprecate previous behaviour
warn(
message = paste(
"The meaning of the 'max' argument has changed compared to",
"previous versions. It now indicates the maximum of a distribution",
"rather than the length of the probability mass function (including 0)",
"that it represented previously. To replicate previous behaviour reduce",
"max by 1.\nThis warning is displayed onc every 8 hours."
),
.frequency = "regularly",
.frequency_id = "dist_spec_max"
)
## check if parametric or nonparametric
if (length(pmf) > 0 &&
!all(
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/setup.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ if (identical(Sys.getenv("NOT_CRAN"), "true")) {
}

withr::defer(future::plan("sequential"), teardown_env())

## process warning once as previous behaviour has been deprecated
empty <- suppressWarnings(dist_spec())


0 comments on commit 928ce19

Please sign in to comment.