Skip to content

Commit

Permalink
style and docs: run devtools::document() and styler::style_pkg()
Browse files Browse the repository at this point in the history
  • Loading branch information
kellijohnson-NOAA authored Jan 14, 2025
1 parent 46a320a commit a75c461
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 55 deletions.
43 changes: 19 additions & 24 deletions R/create_default_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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(
Expand Down
24 changes: 11 additions & 13 deletions R/distribution_formulas.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 6 additions & 7 deletions R/fimsfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
11 changes: 5 additions & 6 deletions R/fimsframe.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
9 changes: 4 additions & 5 deletions R/initialize_modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit a75c461

Please sign in to comment.