Skip to content

Commit

Permalink
Make argument defaults explicit where possible (#729)
Browse files Browse the repository at this point in the history
* Make argument defaults explicit where possible

* Run devtools::document()

* Add NEWS item
  • Loading branch information
Bisaloo authored Jul 25, 2024
1 parent 6a2e3ff commit 2a626c7
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 23 deletions.
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.

0 comments on commit 2a626c7

Please sign in to comment.