From a75c461da05603843291cdf65d9296b2dc2782da Mon Sep 17 00:00:00 2001 From: kellijohnson-NOAA Date: Tue, 14 Jan 2025 19:56:14 +0000 Subject: [PATCH] style and docs: run devtools::document() and styler::style_pkg() --- R/create_default_parameters.R | 43 ++++++++++++++++------------------- R/distribution_formulas.R | 24 +++++++++---------- R/fimsfit.R | 13 +++++------ R/fimsframe.R | 11 ++++----- R/initialize_modules.R | 9 ++++---- 5 files changed, 45 insertions(+), 55 deletions(-) diff --git a/R/create_default_parameters.R b/R/create_default_parameters.R index feff4a26..3ee75343 100644 --- a/R/create_default_parameters.R +++ b/R/create_default_parameters.R @@ -61,16 +61,15 @@ #' ) #' } create_default_parameters <- function( - data, - fleets, - recruitment = list( - form = "BevertonHoltRecruitment", - process_distribution = c(log_devs = "DnormDistribution") - ), - # TODO: Rename EWAAgrowth to not use an acronym - growth = list(form = "EWAAgrowth"), - maturity = list(form = "LogisticMaturity") -) { + data, + fleets, + recruitment = list( + form = "BevertonHoltRecruitment", + process_distribution = c(log_devs = "DnormDistribution") + ), + # TODO: Rename EWAAgrowth to not use an acronym + growth = list(form = "EWAAgrowth"), + maturity = list(form = "LogisticMaturity")) { # FIXME: use default values if there are no fleets info passed into the # function or a fleet is not present but it has data? Maybe we don't want the # latter because it could be that we want to drop a fleet from a model but we @@ -256,8 +255,7 @@ create_default_DoubleLogistic <- function() { #' of selectivity. #' @noRd create_default_selectivity <- function( - form = c("LogisticSelectivity", "DoubleLogisticSelectivity") -) { + form = c("LogisticSelectivity", "DoubleLogisticSelectivity")) { # Input checks form <- rlang::arg_match(form) # NOTE: All new forms of selectivity must be placed in the vector of default @@ -442,10 +440,9 @@ create_default_BevertonHoltRecruitment <- function(data) { #' A list of default parameters for DnormDistribution. #' @noRd create_default_DnormDistribution <- function( - value = 0.1, - data, - input_type = c("data", "process") -) { + value = 0.1, + data, + input_type = c("data", "process")) { # Input checks input_type <- rlang::arg_match(input_type) @@ -486,10 +483,9 @@ create_default_DnormDistribution <- function( #' A list of default parameters for DlnormDistribution. #' @noRd create_default_DlnormDistribution <- function( - value = 0.1, - data, - input_type = c("data", "process") -) { + value = 0.1, + data, + input_type = c("data", "process")) { # Input checks # TODO: Determine if value can be a vector? if (!is.numeric(value) || any(value <= 0, na.rm = TRUE)) { @@ -538,10 +534,9 @@ create_default_DlnormDistribution <- function( #' A list with the default parameters for recruitment. #' @noRd create_default_recruitment <- function( - recruitment, - data, - input_type = "BevertonHoltRecruitment" -) { + recruitment, + data, + input_type = "BevertonHoltRecruitment") { # Input checks if (!is.list(recruitment)) { cli::cli_abort(c( diff --git a/R/distribution_formulas.R b/R/distribution_formulas.R index 1d0115ff..df3ee208 100644 --- a/R/distribution_formulas.R +++ b/R/distribution_formulas.R @@ -252,13 +252,12 @@ get_expected_name <- function(family, data_type) { #' ) #' } initialize_data_distribution <- function( - module, - family, - sd = list(value = 1, estimated = FALSE), - # FIXME: Move this argument to second to match where par is in - # initialize_process_distribution - data_type = c("index", "agecomp", "lengthcomp") -) { + module, + family, + sd = list(value = 1, estimated = FALSE), + # FIXME: Move this argument to second to match where par is in + # initialize_process_distribution + data_type = c("index", "agecomp", "lengthcomp")) { data_type <- rlang::arg_match(data_type) # FIXME: Make the available families a data object # Could also make the matrix of distributions available per type as a @@ -345,12 +344,11 @@ initialize_data_distribution <- function( #' @keywords distribution #' @export initialize_process_distribution <- function( - module, - par, - family, - sd = list(value = 1, estimated = FALSE), - is_random_effect = FALSE -) { + module, + par, + family, + sd = list(value = 1, estimated = FALSE), + is_random_effect = FALSE) { # validity check on user input args <- list(family = family, sd = sd) check_distribution_validity(args) diff --git a/R/fimsfit.R b/R/fimsfit.R index dd2385fd..b79b7bba 100644 --- a/R/fimsfit.R +++ b/R/fimsfit.R @@ -337,13 +337,12 @@ is.FIMSFits <- function(x) { #' @keywords fit_fims #' @export FIMSFit <- function( - input, - obj, - opt = list(), - sdreport = list(), - timing = c("time_total" = as.difftime(0, units = "secs")), - version = utils::packageVersion("FIMS") -) { + input, + obj, + opt = list(), + sdreport = list(), + timing = c("time_total" = as.difftime(0, units = "secs")), + version = utils::packageVersion("FIMS")) { # What we aspire the estimate table to look like estimates_outline <- dplyr::tibble( label = character(), diff --git a/R/fimsframe.R b/R/fimsframe.R index da7f3336..22500389 100644 --- a/R/fimsframe.R +++ b/R/fimsframe.R @@ -805,12 +805,11 @@ FIMSFrame <- function(data) { # Unexported functions ---- create_missing_data <- function( - data, - bins, - years, - column, - types = c("landings", "index") -) { + data, + bins, + years, + column, + types = c("landings", "index")) { use_this_data <- data |> dplyr::group_by(type, name) out_data <- if (missing(bins)) { diff --git a/R/initialize_modules.R b/R/initialize_modules.R index 4e4c905d..425698c9 100644 --- a/R/initialize_modules.R +++ b/R/initialize_modules.R @@ -206,11 +206,10 @@ initialize_module <- function(parameters, data, module_name) { #' The initialized distribution module as an object. #' @noRd initialize_distribution <- function( - module_input, - distribution_name, - distribution_type = c("data", "process"), - linked_ids -) { + module_input, + distribution_name, + distribution_type = c("data", "process"), + linked_ids) { # Input checks # Check if distribution_name is provided if (is.null(distribution_name)) {