Skip to content

Commit

Permalink
Skip checking parameters of nonparametric distributions (#750)
Browse files Browse the repository at this point in the history
* Skip checking parameters of nonparametric distributions

* Fix distribution getting step of composite distribution

* Add NEWS item

* Fix code style
  • Loading branch information
jamesmbaazam authored Aug 27, 2024
1 parent 1fb9c33 commit 5ce0043
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
- a bug was fixed where `forecast_secondary()` did not work with fixed delays. By @sbfnk in #717 and reviewed by @seabbs.
- a bug was fixed that caused delay option functions to report an error if only the tolerance was specified. By @sbfnk.
- a bug was fixed that led to the truncation PMF being shortened from the wrong side when the truncation PMF was longer than the supplied data. By @seabbs in #736 and reviewed by @sbfnk and @jamesmbaazam.
- a bug was fixed that caused internal validation checks on delay distributions to fail if they contained non-parametric distributions. By @jamesmbaazam in #750 and reviewed by @seabbs.

## Documentation

Expand Down
14 changes: 8 additions & 6 deletions R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,14 @@ check_stan_delay <- function(dist) {
# Check that `dist` has parameters that are either numeric or normal
# distributions with numeric parameters and infinite maximum
numeric_or_normal <- unlist(lapply(seq_len(ndist(dist)), function(id) {
params <- get_parameters(dist, id)
vapply(params, function(x) {
is.numeric(x) ||
(is(x, "dist_spec") && get_distribution(x) == "normal" &&
is.infinite(max(x)))
}, logical(1))
if (get_distribution(dist, id) != "nonparametric") {
params <- get_parameters(dist, id)
vapply(params, function(x) {
is.numeric(x) ||
(is(x, "dist_spec") && get_distribution(x) == "normal" &&
is.infinite(max(x)))
}, logical(1))
}
}))
if (!all(numeric_or_normal)) {
stop(
Expand Down

0 comments on commit 5ce0043

Please sign in to comment.