Skip to content
Draft
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: 1 addition & 1 deletion .github/workflows/build-doxygen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Get repository
uses: actions/checkout@v4
uses: actions/checkout@v5

- name: Installing build dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/call-allcontributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Setup R
uses: r-lib/actions/setup-r@v2

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/get-gtest-codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Install Ninja
run: sudo apt-get install ninja-build
- uses: r-lib/actions/setup-r@v2
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/greetings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ name: Greetings

on: [pull_request_target, issues]

permissions:
issues: write
pull-requests: write

jobs:
greeting:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/first-interaction@v1
- uses: actions/first-interaction@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: >
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
# Format hpp and cpp files under inst/include, src/, and test/gtest
# We use Google style to format code.
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- uses: DoozyX/clang-format-lint-action@v0.20
with:
source: './inst/include ./src ./tests/gtest'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5

- name: install clang-tidy
run: sudo apt update && sudo apt -y install clang-tidy
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-googletest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Install Ninja
shell: bash
run: ${{ runner.os == 'macOS' && 'brew install ninja' || runner.os == 'Windows' && 'choco install ninja' || 'sudo apt-get install ninja-build' }}
Expand Down
29 changes: 0 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,6 @@ IF(BUILD_DOC)
COMMENT "Building documentation with Doxygen.")
ENDIF()

# Set up Rcpp
FetchContent_Declare(
rcpp
URL https://github.com/RcppCore/Rcpp/archive/refs/tags/1.0.8.zip
)
FetchContent_MakeAvailable(rcpp)

# Set up R
MESSAGE(STATUS "Looking for R executable")

EXECUTE_PROCESS(
COMMAND which R
OUTPUT_VARIABLE R_EXECUTABLE)

MESSAGE(STATUS "R_EXECUTABLE is ${R_EXECUTABLE}")

EXECUTE_PROCESS(
COMMAND R "--slave" "--no-save" "-e" "cat(R.home())"
OUTPUT_VARIABLE R_HOME)

MESSAGE(STATUS "R_HOME is ${R_HOME}")

EXECUTE_PROCESS(
COMMAND R "--slave" "--no-save" "-e" "remotes::install_local(upgrade = 'always')")
EXECUTE_PROCESS(
COMMAND R "--slave" "--no-save" "-e" "FIMS:::setup_gtest()")

# Enable testing for current directory and below
enable_testing()

Expand All @@ -91,8 +64,6 @@ add_library(fims_test INTERFACE)
target_include_directories(fims_test
INTERFACE
inst/include
${rcpp_SOURCE_DIR}/inst/include
${R_HOME}/include
)

# Add compile definition STD_LIB to the fims_test target.
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export(initialize_process_distribution)
export(initialize_process_structure)
export(inv_logit)
export(is.FIMSFit)
export(is.FIMSFits)
export(log_error)
export(log_info)
export(log_warning)
Expand Down
3 changes: 1 addition & 2 deletions R/check_fims.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ setup_gtest <- function() {
#' @keywords developer
#' @examples
#' \dontrun{
#' # TODO: add examples of strings passed to `...`
#' setup_and_run_gtest()
#' setup_and_run_gtest("--rerun-failed --output-on-failure")
#' }
setup_and_run_gtest <- function(...) {
setup_gtest()
Expand Down
76 changes: 76 additions & 0 deletions R/data.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#' FIMS input data frame
#'
#' A dataset containing information necessary to run an age-structured stock
#' assessment model in FIMS. This data was generated using
#' the `ASSAMC` package written for the [model comparison project](
#' www.github.com/NOAA-FIMS/Age_Structured_Stock_Assessment_Model_Comparison).
#'
#' @format
#' A data frame with `r NROW(data1)` observations of `r NCOL(data1)`
#' variables:
#' \describe{ \item{type}{The type of data the row contains. Allowed types
#' include `age`, `length`, `index`, `landings`, `age-to-length-conversion`,
#' and `weight-at-age` data.}
#' \item{name}{A character string providing the name of the information source
#' that the data was collected from, e.g., `"Trawl fishery"`.}
#' \item{age}{An integer age. Entry can be `NA` if information pertains to
#' multiple ages, e.g., total landings rather than landings of age-4 fish.}
#' \item{length}{A numeric length. Entry can be `NA` if information doesn't
#' pertain to length.}
#' \item{datestart,dateend}{Start and end dates of the data collection period.
#' Format all dates using `yyyy-mm-dd`, which can accommodate fake years
#' such as `0001-01-01`.}
#' \item{value}{The measurement of interest.}
#' \item{unit}{A character string specifying the units of `value`. Allowed
#' units for each data type are as follows. `mt` is used for `index`,
#' `landings`, and `weight-at-age` data. `number` or `proportion` are each
#' viable units for the composition data, where the former is the preferred
#' unit of measurement.}
#' \item{uncertainty}{A real value providing a measurement of uncertainty
#' for value. For landings and indices of abundance this should be
#' the standard deviation of the logged observations if you are using the
#' lognormal distribution to fit your data. For composition data it will
#' be your input sample size.
#' }
#' }
#' @source \url{www.github.com/NOAA-FIMS/Age_Structured_Stock_Assessment_Model_Comparison}
"data1"

#' small FIMS input data frame
#'
#' A dataset containing minimal information necessary to run an
#' age-structured stock
#' assessment model in FIMS. This data was generated using the script in
#' `/data-raw/data_small.R` and does not correspond to any realistic population
#' or sampling method (the values are mostly arbitrary).
#'
#' @format
#' A data frame with `r NROW(data_small)` observations of `r NCOL(data_small)`
#' variables:
#' \describe{ \item{type}{The type of data the row contains. Allowed types
#' include `age`, `length`, `index`, `landings`, `age-to-length-conversion`,
#' and `weight-at-age` data.}
#' \item{name}{A character string providing the name of the information source
#' that the data was collected from, e.g., `"Trawl fishery"`.}
#' \item{age}{An integer age. Entry can be `NA` if information pertains to
#' multiple ages, e.g., total landings rather than landings of age-4 fish.}
#' \item{length}{A numeric length. Entry can be `NA` if information doesn't
#' pertain to length.}
#' \item{datestart,dateend}{Start and end dates of the data collection period.
#' Format all dates using `yyyy-mm-dd`, which can accommodate fake years
#' such as `0001-01-01`.}
#' \item{value}{The measurement of interest.}
#' \item{unit}{A character string specifying the units of `value`. Allowed
#' units for each data type are as follows. `mt` is used for `index`,
#' `landings`, and `weight-at-age` data. `number` or `proportion` are each
#' viable units for the composition data, where the former is the preferred
#' unit of measurement.}
#' \item{uncertainty}{A real value providing a measurement of uncertainty
#' for value. For landings and indices of abundance this should be
#' the standard deviation of the logged observations if you are using the
#' lognormal distribution to fit your data. For composition data it will
#' be your input sample size.
#' }
#' }
#' @source None, this is a simulated dataset full of arbitrary values as defined in `/data-raw/data_small.R`.
"data_small"
37 changes: 0 additions & 37 deletions R/data1.R

This file was deleted.

2 changes: 1 addition & 1 deletion R/distribution_formulas.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ initialize_data_distribution <- function(
new_module <- methods::new(DlnormDistribution)

# populate logged standard deviation parameter with log of input
# Using resize() and then assigning value to each element of log_sd diretly
# Using resize() and then assigning value to each element of log_sd directly
# is correct, as creating a new ParameterVector for log_sd here would
# trigger an error in integration tests with wrappers.
new_module$log_sd$resize(length(sd[["value"]]))
Expand Down
36 changes: 14 additions & 22 deletions R/fimsfit.R
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ utils::globalVariables(c(
# TODO: Fix "no metadata object found to revise superClass" in sdreportOrList
# TODO: Write more validity checks for FIMSFit
# TODO: Better document the return of [get_estimates()], i.e., columns
# TODO: Decide if the error from is.FIMSFits should be a single FALSE or stop
# TODO: Decide if "total" should be a part of number_of_parameters because it
# can be calculated from fixed_effects + random_effects and would need to
# be calculated in print.FITFims()
# TODO: Determine if report should always use last.par.best
# TODO: Make a helper function to add lower and upper CI for users in estimates

# methods::setClass: ----
Expand Down Expand Up @@ -95,6 +90,12 @@ methods::setMethod(
x@number_of_parameters,
sep = "="
)
total_parameters <- sum(x@number_of_parameters)
all_parameters_info <- c(number_of_parameters, paste(
"total",
total_parameters,
sep = "="
))
div_digit <- cli::cli_div(theme = list(.val = list(digits = 5)))
terminal_ssb <- sapply(
x@report[["ssb"]],
Expand All @@ -103,7 +104,7 @@ methods::setMethod(
cli::cli_inform(c(
"i" = "FIMS model version: {.val {x@version}}",
"i" = "Total run time was {.val {rt}} {ru}",
"i" = "Number of parameters: {number_of_parameters}",
"i" = "Number of parameters: {all_parameters_info}",
"i" = "Maximum gradient= {.val {x@max_gradient}}",
"i" = "Negative log likelihood (NLL):",
"*" = "Marginal NLL= {.val {x@opt$objective}}",
Expand Down Expand Up @@ -343,21 +344,6 @@ is.FIMSFit <- function(x) {
inherits(x, "FIMSFit")
}

#' Check if an object is a list of FIMSFit objects
#'
#' @param x List of fits returned from multiple calls to [fit_fims()].
#' @keywords fit_fims
#' @export
is.FIMSFits <- function(x) {
if (!is.list(x)) {
cli::cli_warn(
message = c("x" = "{.par x} is not a list -- something went wrong.")
)
return(FALSE)
}
all(sapply(x, function(i) inherits(i, "FIMSFit")))
}

# Constructors ----

#' Class constructors for class `FIMSFit` and associated child classes
Expand Down Expand Up @@ -431,7 +417,6 @@ FIMSFit <- function(
n_fixed_effects <- length(obj[["par"]])
n_random_effects <- length(obj[["env"]][["parList()"]][["re"]])
number_of_parameters <- c(
total = n_total,
fixed_effects = n_fixed_effects,
random_effects = n_random_effects
)
Expand Down Expand Up @@ -712,6 +697,13 @@ fit_fims <- function(input,
trace = 0
),
filename = NULL) {
# See issue 455 of sdmTMB to see what should be used.
# https://github.com/pbs-assess/sdmTMB/issues/455
# NOTE: When we add implementation for newton step we need to
# review the above github issue to make sure we maintain continuity
# between outputs as last.par may not equal last.par.best due to
# the smallest newton gradient solution not matching the smallest
# likelihood value. This can cause sanity issues in output reporting.
if (number_of_newton_steps > 0) {
cli::cli_abort("Newton steps not implemented yet.")
}
Expand Down
9 changes: 0 additions & 9 deletions R/initialize_modules.R
Original file line number Diff line number Diff line change
Expand Up @@ -820,15 +820,6 @@ initialize_fims <- function(parameters, data) {
data_type = "landings"
)
}
# TODO (Matthew): Determine if the "dims" field is required for DmultinomDistribution.
# We need to decide whether to:
# 1. Remove the "dims" field to maintain consistency with other distributions, or
# 2. Update all relevant R functions (e.g., initialize_data_distribution())
# that call DmultinomDistribution to set the "dims" field.
# AMH comment:
# 1. dims field is needed to track the dimension of multivariate input
# 2. the pattern for multinomial is different because it is a multivariate distribution.
# Other multivariate distributions (e.g. MVNORM) will likely also need a dims field

if ("age" %in% fleet_types &&
"AgeComp" %in% data_distribution_names_for_fleet_i) {
Expand Down
2 changes: 1 addition & 1 deletion R/reshape_output.R
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ reshape_tmb_estimates <- function(obj,
opt = NULL,
parameter_names) {
# Outline for the estimates table
# TODO: The fleet_name, age, length, and time columns are currently emplty. Matthew
# TODO: The fleet_name, age, length, and time columns are currently empty. Matthew
# has started adding information to the JSON output in the dev-model-families branch.
# We can populate these columns once the dev-model-families branch is merged
# into dev.
Expand Down
Loading
Loading