Skip to content

Commit

Permalink
use tail for check (#802)
Browse files Browse the repository at this point in the history
* use `tail` for check

* add news item

* add regression test
  • Loading branch information
sbfnk authored Sep 30, 2024
1 parent 6970f49 commit de1e374
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ A release that introduces model improvements to the Gaussian Process models, alo
- Switch to broadcasting from random walks and added unit tests. By @seabbs in #747 and reviewed by @jamesmbaazam.
- Optimised convolution code to take into account the relative length of the vectors being convolved. See #745 by @seabbs and reviewed by @jamesmbaazam.
- Switch to broadcasting the day of the week effect. By @seabbs in #746 and reviewed by @jamesmbaazam.
- A warning is now thrown if nonparametric PMFs passed to delay options have consecutive tail values that are below a certain low threshold as these lead to loss in speed with little gain in accuracy. By @jamesmbaazam in #752 and reviewed by @seabbs.
- A warning is now thrown if nonparametric PMFs passed to delay options have consecutive tail values that are below a certain low threshold as these lead to loss in speed with little gain in accuracy. By @jamesmbaazam in #752 and reviewed by @seabbs, with a subsequent bug fix in #802.
- `dist_fit()` can now accept any number of `samples` without throwing a warning when `samples` < 1000 in #751 by @jamesmbaazam and reviewed by @seabbs and @sbfnk.

## Package changes
Expand Down
2 changes: 1 addition & 1 deletion R/checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ check_stan_delay <- function(dist) {
#' @return Called for its side effects.
#' @keywords internal
check_sparse_pmf_tail <- function(pmf, span = 5, tol = 1e-6) {
if (all(pmf[(length(pmf) - span + 1):length(pmf)] < tol)) {
if (all(tail(pmf, span) < tol)) {
cli_warn(
c(
"!" = "The PMF tail has {col_blue(span)} consecutive value{?s} smaller
Expand Down
7 changes: 7 additions & 0 deletions tests/testthat/test-delays.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ test_that("delay parameters can be specified in different ways", {
), digits = 2), n = -2),
c(0.08, 0.33, 0.36, 0.16, 0.05, 0.02, 0.01, 0.00, 0.00, 1.00)
)
expect_equal(
test_stan_delays(
delays = delay_opts(NonParametric(pmf = c(0.1, 0.6, 0.3))),
params = delay_params
),
c(0.0, 1.0, 0.1, 0.6, 0.3, 1.0)
)
})

test_that("truncation parameters can be specified in different ways", {
Expand Down

0 comments on commit de1e374

Please sign in to comment.