Skip to content

Make argument defaults explicit where possible #729

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

Merged
merged 3 commits into from
Jul 25, 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 @@ -2,6 +2,7 @@

## Documentation

- Some implicit argument defaults have been made explicit in the function definition. By @Bisaloo in #729.
- The installation guide in the README has been updated to provide instructions for configuring the C toolchain of Windows, MacOS, and Linux. By @jamesmbaazam in #707 and reviewed by @sbfnk.

## Model changes
Expand Down
6 changes: 1 addition & 5 deletions R/epinow.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ epinow <- function(data,
CrIs = c(0.2, 0.5, 0.9),
filter_leading_zeros = TRUE,
zero_threshold = Inf,
return_output = FALSE,
return_output = is.null(target_folder),
output = c("samples", "plots", "latest", "fit", "timing"),
plot_args = list(),
target_folder = NULL, target_date,
Expand All @@ -116,10 +116,6 @@ epinow <- function(data,
assert_string(id)
assert_logical(verbose)

if (is.null(target_folder)) {
return_output <- TRUE
}

if (is.null(CrIs) || length(CrIs) == 0 || !is.numeric(CrIs)) {
futile.logger::flog.fatal(
"At least one credible interval must be specified",
Expand Down
3 changes: 1 addition & 2 deletions R/regional_epinow.R
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ regional_epinow <- function(data,
"regions", "summary", "samples",
"plots", "latest"
),
return_output = FALSE,
return_output = is.null(target_folder),
summary_args = list(),
verbose = FALSE,
logs = tempdir(check = TRUE), ...,
Expand Down Expand Up @@ -148,7 +148,6 @@ regional_epinow <- function(data,
futile.logger::flog.info(
"No target directory specified so returning output"
)
return_output <- TRUE
} else {
futile.logger::flog.info("Saving estimates to : %s", target_folder)
}
Expand Down
9 changes: 2 additions & 7 deletions R/summarise.R
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
summarise_results <- function(regions,
summaries = NULL,
results_dir = NULL,
target_date = NULL,
target_date = "latest",
region_scale = "Region") {
if (is.null(target_date)) {
target_date <- "latest"
}

if (is.null(results_dir)) {
if (is.null(summaries)) {
stop(
Expand Down Expand Up @@ -181,7 +177,7 @@ regional_summary <- function(regional_output = NULL,
target_date = NULL,
region_scale = "Region",
all_regions = TRUE,
return_output = FALSE,
return_output = is.null(summary_dir),
plot = TRUE,
max_plot = 10,
...) {
Expand All @@ -190,7 +186,6 @@ regional_summary <- function(regional_output = NULL,
futile.logger::flog.info(
"No summary directory specified so returning summary output"
)
return_output <- TRUE
} else {
futile.logger::flog.info("Saving summary to : %s", summary_dir)
}
Expand Down
5 changes: 1 addition & 4 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@
#' @importFrom futile.logger flog.info
#' @return No return value, called for side effects
#' @export
clean_nowcasts <- function(date = NULL, nowcast_dir = ".") {
if (is.null(date)) {
date <- Sys.Date()
}
clean_nowcasts <- function(date = Sys.Date(), nowcast_dir = ".") {
dirs <- list.dirs(nowcast_dir, recursive = FALSE)
purrr::walk(
dirs,
Expand Down
2 changes: 1 addition & 1 deletion man/clean_nowcasts.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/epinow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/regional_epinow.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/regional_summary.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/summarise_results.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading