-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 735: Fix truncation slicing when t < truncation (#736)
* Fix truncation slicing when t < truncation * add news item * add unit tests for truncate vs relying on integration testing * add documentation for observation models * Apply suggestions from code review Co-authored-by: Sebastian Funk <[email protected]> * hack around truncate overloading * use the correct stan functions * rename truncate -> truncate_obs * Update NEWS.md Co-authored-by: James Azam <[email protected]> --------- Co-authored-by: Sebastian Funk <[email protected]> Co-authored-by: James Azam <[email protected]>
- Loading branch information
1 parent
03fc897
commit 22e5b22
Showing
8 changed files
with
135 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
skip_on_cran() | ||
skip_on_os("windows") | ||
|
||
test_that("truncate_obs() can perform truncation as expected", { | ||
reports <- c(10, 20, 30, 40, 50) | ||
trunc_rev_cmf <- c(1, 0.8, 0.5, 0.2) | ||
expected <- c(reports[1], reports[2:5] * trunc_rev_cmf) | ||
expect_equal(truncate_obs(reports, trunc_rev_cmf, FALSE), expected) | ||
}) | ||
|
||
test_that("truncate_obs() can perform reconstruction as expected", { | ||
reports <- c(10, 20, 15, 8, 10) | ||
trunc_rev_cmf <- c(1, 0.8, 0.5, 0.2) | ||
expected <- c(reports[1], reports[2:5] / trunc_rev_cmf) | ||
expect_equal(truncate_obs(reports, trunc_rev_cmf, TRUE), expected) | ||
}) | ||
|
||
test_that("truncate_obs() can handle longer trunc_rev_cmf than reports", { | ||
reports <- c(10, 20, 30) | ||
trunc_rev_cmf <- c(1, 0.8, 0.5, 0.2, 0.1) | ||
expected <- reports * trunc_rev_cmf[3:5] | ||
expect_equal(truncate_obs(reports, trunc_rev_cmf, FALSE), expected) | ||
}) | ||
|
||
test_that("truncate_obs() can handle reconstruction with longer trunc_rev_cmf than reports", { | ||
reports <- c(10, 16, 15) | ||
trunc_rev_cmf <- c(1, 0.8, 0.5, 0.2, 0.1) | ||
expected <- reports / trunc_rev_cmf[3:5] | ||
expect_equal(truncate_obs(reports, trunc_rev_cmf, TRUE), expected) | ||
}) |