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

cleanup from attempted run #55

Merged
merged 6 commits into from
Oct 15, 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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,5 @@
* Specify number of samples draws with `iter_sampling`
* Fix NOTE from missing variable name used with NSE
* Read from new parameters schema
* Fix bugs in parameter reading from local test run
* Fix bugs in parameter reading from local test run
13 changes: 11 additions & 2 deletions R/fit_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,24 @@ format_right_truncation <- function(pmf, data) {
# silently removed if length of the PMF was longer than the data,
# effectively eliminating the right-truncation correction

cli::cli_abort(
trunc_len <- nrow(data)
cli::cli_warn(
c(
"Removing right-truncation PMF elements after {.val {trunc_len}}",
"Right truncation PMF longer than the data",
"PMF length: {.val {length(pmf)}}",
"Data length: {.val {nrow(data)}}",
"PMF can only be up to length as the data"
"PMF can only be up to the length of the data"
),
class = "right_trunc_too_long"
)
suppressWarnings({
EpiNow2::trunc_opts(
zsusswein marked this conversation as resolved.
Show resolved Hide resolved
dist = EpiNow2::dist_spec(
pmf = pmf[seq_len(trunc_len)]
)
)
})
} else {
suppressWarnings({
EpiNow2::trunc_opts(
Expand Down
2 changes: 1 addition & 1 deletion R/parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ read_interval_pmf <- function(path,
rlang::arg_match(disease)

as_of_date <- stringify_date(as_of_date)
cli::cli_alert_info("Reading {.arg right_truncation} from {.path {path}}")
cli::cli_alert_info("Reading {.arg {parameter}} from {.path {path}}")
if (!file.exists(path)) {
cli::cli_abort("File {.path {path}} does not exist",
class = "file_not_found"
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/_snaps/fit_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Right truncation longer than data throws error

Removing right-truncation PMF elements after 2
Right truncation PMF longer than the data
PMF length: 3
Data length: 2
PMF can only be up to the length of the data

5 changes: 2 additions & 3 deletions tests/testthat/test-fit_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -178,12 +178,11 @@ test_that("Right truncation longer than data throws error", {
data <- data.frame(x = c(1, 2))
right_truncation_pmf <- c(0.1, 0.2, 0.7)

expect_error(
expect_snapshot_warning(
format_right_truncation(
right_truncation_pmf,
data
),
class = "right_trunc_too_long"
)
)
})

Expand Down
Loading