Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip checking parameters of nonparametric distributions #750

Merged
merged 4 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading