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

Style code and document #714

Merged
merged 1 commit into from
Jan 3, 2025
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: 0 additions & 2 deletions .github/workflows/call-calc-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ name: call-calc_coverage
# The default is to run the workflow on every push or pull request to every branch.
on:
workflow_dispatch:
push:
on: workflow_dispatch
paths-ignore:
- .devcontainer
- .github
Expand Down
154 changes: 38 additions & 116 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -2,122 +2,44 @@ Package: FIMS
Title: The Fisheries Integrated Modeling System
Version: 0.3.0.0
Authors@R: c(
person(
role = c("aut", "cre"),
family = "Johnson",
given = c("Kelli", "F."),
email = "[email protected]",
comment = c(ORCID = "0000-0002-5149-451X")
),
person(
role = "aut",
family = "Brodziak",
given = c("Jon", "K.", "T."),
comment = c(ORCID = "0000-0001-8690-5588")
),
person(
role = "aut",
family = "Doering",
given = c("Kathryn", "L."),
comment = c(ORCID = "0000-0002-0396-7044")
),
person(
role = "aut",
family = "Havron",
given = c("Andrea", "M."),
comment = c(ORCID = "0000-0002-4080-448X")
),
person(
role = "aut",
family = "Klasky",
given = c("Ronald"),
comment = c(ORCID = "0009-0004-7563-7716")
),
person(
role = "aut",
family = "Kuriyama",
given = c("Peter", "T."),
comment = c(ORCID = "0000-0002-6971-4015")
),
person(
role = "aut",
family = "Legault",
given = c("Christopher", "M."),
comment = c(ORCID = "0000-0002-0328-1376")
),
person(
role = "aut",
family = "Li",
given = "Bai",
comment = c(ORCID = "0000-0002-8249-1442")
),
person(
role = "aut",
family = "Miller",
given = c("Timothy", "J."),
comment = c(ORCID = "0000-0003-1411-1206")
),
person(
role = "aut",
family = "Monnahan",
given = c("Cole", "C."),
comment = c(ORCID = "0000-0003-0871-6700")
),
person(
role = "aut",
family = "Oshima",
given = c("Megumi", "C."),
comment = c(ORCID = "0009-0002-2239-1594")
),
person(
role = "aut",
family = "Shertzer",
given = c("Kyle", "W."),
comment = c(ORCID = "0000-0001-7196-5959")
),
person(
role = "aut",
family = "Stawitz",
given = c("Christine", "C."),
email = "[email protected]",
comment = c(ORCID = "0000-0003-3122-4501")
),
person(
role = "aut",
family = "Sullivan",
given = c("Jane", "Y."),
comment = c(ORCID = "0000-0002-8094-1673")
),
person(
role = "aut",
family = "Supernaw",
given = "Matthew",
comment = c(ORCID = "0009-0007-3681-7433")
),
person(
role = "aut",
family = "Taylor",
given = c("Ian", "G."),
comment = c(ORCID = "0000-0002-4232-5669")
),
person(
role = "aut",
family = "Vaughan",
given = c("Nathan", "R."),
comment = c(ORCID = "0009-0000-3054-6950")
),
person(
role = "ctb",
family = "Blackhart",
given = "Kristan",
comment = c(ORCID = "0000-0003-4232-2510")
),
person(
role = "ctb",
family = "Ianelli",
given = c("James", "N."),
comment = c(ORCID = "0000-0002-7170-8677")
)
person(c("Kelli", "F."), "Johnson", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-5149-451X")),
person(c("Jon", "K.", "T."), "Brodziak", role = "aut",
comment = c(ORCID = "0000-0001-8690-5588")),
person(c("Kathryn", "L."), "Doering", role = "aut",
comment = c(ORCID = "0000-0002-0396-7044")),
person(c("Andrea", "M."), "Havron", role = "aut",
comment = c(ORCID = "0000-0002-4080-448X")),
person("Ronald", "Klasky", role = "aut",
comment = c(ORCID = "0009-0004-7563-7716")),
person(c("Peter", "T."), "Kuriyama", role = "aut",
comment = c(ORCID = "0000-0002-6971-4015")),
person(c("Christopher", "M."), "Legault", role = "aut",
comment = c(ORCID = "0000-0002-0328-1376")),
person("Bai", "Li", role = "aut",
comment = c(ORCID = "0000-0002-8249-1442")),
person(c("Timothy", "J."), "Miller", role = "aut",
comment = c(ORCID = "0000-0003-1411-1206")),
person(c("Cole", "C."), "Monnahan", role = "aut",
comment = c(ORCID = "0000-0003-0871-6700")),
person(c("Megumi", "C."), "Oshima", role = "aut",
comment = c(ORCID = "0009-0002-2239-1594")),
person(c("Kyle", "W."), "Shertzer", role = "aut",
comment = c(ORCID = "0000-0001-7196-5959")),
person(c("Christine", "C."), "Stawitz", , "[email protected]", role = "aut",
comment = c(ORCID = "0000-0003-3122-4501")),
person(c("Jane", "Y."), "Sullivan", role = "aut",
comment = c(ORCID = "0000-0002-8094-1673")),
person("Matthew", "Supernaw", role = "aut",
comment = c(ORCID = "0009-0007-3681-7433")),
person(c("Ian", "G."), "Taylor", role = "aut",
comment = c(ORCID = "0000-0002-4232-5669")),
person(c("Nathan", "R."), "Vaughan", role = "aut",
comment = c(ORCID = "0009-0000-3054-6950")),
person("Kristan", "Blackhart", role = "ctb",
comment = c(ORCID = "0000-0003-4232-2510")),
person(c("James", "N."), "Ianelli", role = "ctb",
comment = c(ORCID = "0000-0002-7170-8677"))
)
Description: The Fisheries Integrated Modeling System is a next-generation
framework of stock assessment models, assisting fishery managers with
Expand Down
20 changes: 9 additions & 11 deletions R/create_default_parameters.R
Original file line number Diff line number Diff line change
Expand Up @@ -344,8 +344,7 @@ create_default_fleet <- function(fleets,
dplyr::arrange(dplyr::desc(type)) |>
dplyr::pull(uncertainty)

index_distribution_default <- switch(
index_distribution,
index_distribution_default <- switch(index_distribution,
"DnormDistribution" = create_default_DnormDistribution(
value = index_uncertainty,
input_type = "data",
Expand All @@ -367,8 +366,8 @@ create_default_fleet <- function(fleets,
default <- list(c(
selectivity_default,
process_default,
index_distribution_default)
)
index_distribution_default
))

names(default) <- fleet_name
return(default)
Expand Down Expand Up @@ -523,7 +522,7 @@ create_default_DlnormDistribution <- function(
}

#' Create default recruitment parameters
#'#'
#'
#' @description
#' This function sets up default parameters for a recruitment module.
#'
Expand All @@ -541,7 +540,8 @@ create_default_DlnormDistribution <- function(
create_default_recruitment <- function(
recruitment,
data,
input_type = "BevertonHoltRecruitment") {
input_type = "BevertonHoltRecruitment"
) {
# Input checks
if (!is.list(recruitment)) {
cli::cli_abort(c(
Expand All @@ -554,8 +554,7 @@ create_default_recruitment <- function(
# NOTE: All new forms of recruitment must be placed in the vector of default
# arguments for `form` and their methods but be placed below in the call to
# `switch`
process_default <- switch(
form,
process_default <- switch(form,
"BevertonHoltRecruitment" = create_default_BevertonHoltRecruitment(data)
)
names(process_default) <- paste0(form, ".", names(process_default))
Expand All @@ -564,8 +563,7 @@ create_default_recruitment <- function(
distribution_input <- recruitment[["process_distribution"]]
distribution_default <- NULL
if (!is.null(distribution_input)) {
distribution_default <- switch(
distribution_input,
distribution_default <- switch(distribution_input,
"DnormDistribution" = create_default_DnormDistribution(
data = data,
input_type = "process"
Expand Down Expand Up @@ -614,7 +612,7 @@ update_parameters <- function(current_parameters, modified_parameters) {
# Check if current_parameters is a list with required components
if (
!is.list(current_parameters) ||
!all(c("parameters", "modules") %in% names(current_parameters))
!all(c("parameters", "modules") %in% names(current_parameters))
) {
cli::cli_abort(c(
"i" = "{.var current_parameters} argument must be a list containing
Expand Down
18 changes: 9 additions & 9 deletions R/distribution_formulas.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ check_distribution_validity <- function(args) {
}
if (
!(family[["family"]] %in% available_distributions) ||
"unavailable data type" %in% available_distributions
"unavailable data type" %in% available_distributions
) {
ifelse_type <- ifelse(
is.null(data_type),
Expand Down Expand Up @@ -120,7 +120,7 @@ check_distribution_validity <- function(args) {
}
if (
length(sd[["estimated"]]) > 1 &&
length(sd[["value"]]) != length(sd[["estimated"]])
length(sd[["value"]]) != length(sd[["estimated"]])
) {
sd_length <- length(sd[["value"]])
est_length <- length(sd[["estimated"]])
Expand Down Expand Up @@ -236,7 +236,7 @@ get_expected_name <- function(family, data_type) {
#' ),
#' data_type = "index"
#' )
#'
#'
#' # Set up a new process distribution
#' # Create a new recruitment module
#' recruitment <- methods::new(BevertonHoltRecruitment)
Expand All @@ -263,7 +263,7 @@ initialize_data_distribution <- function(
# FIXME: Make the available families a data object
# Could also make the matrix of distributions available per type as a
# data frame where the check could use the stored object.


# validity check on user input
args <- list(
Expand Down Expand Up @@ -303,7 +303,7 @@ initialize_data_distribution <- function(

# populate logged standard deviation parameter with log of input
new_module$log_sd$resize(length(sd[["value"]]))
for (i in seq_along(sd[["value"]])){
for (i in seq_along(sd[["value"]])) {
new_module$log_sd[i]$value <- log(sd[["value"]][i])
}

Expand All @@ -318,7 +318,7 @@ initialize_data_distribution <- function(
}

if (family[["family"]] == "multinomial") {
#create new Rcpp module
# create new Rcpp module
new_module <- methods::new(DmultinomDistribution)
}

Expand Down Expand Up @@ -366,7 +366,7 @@ initialize_process_distribution <- function(
log(sd[["value"]]),
length(sd[["value"]])
)
#setup whether or not sd parameter is estimated
# setup whether or not sd parameter is estimated
if (length(sd[["value"]]) > 1 && length(sd[["estimated"]]) == 1) {
new_module$log_sd$set_all_estimable(sd[["estimated"]])
} else {
Expand All @@ -382,11 +382,11 @@ initialize_process_distribution <- function(

# populate logged standard deviation parameter with log of input
new_module$log_sd$resize(length(sd[["value"]]))
for (i in seq_along(sd[["value"]])){
for (i in seq_along(sd[["value"]])) {
new_module$log_sd[i]$value <- log(sd[["value"]][i])
}

#setup whether or not sd parameter is estimated
# setup whether or not sd parameter is estimated
if (length(sd[["value"]]) > 1 && length(sd[["estimated"]]) == 1) {
new_module$log_sd$set_all_estimable(sd[["estimated"]])
} else {
Expand Down
Loading
Loading