Skip to content

[WIP] Remove mean F calculation for functional groups#17

Closed
Copilot wants to merge 15 commits intomainfrom
copilot/remove-mean-f-calculation
Closed

[WIP] Remove mean F calculation for functional groups#17
Copilot wants to merge 15 commits intomainfrom
copilot/remove-mean-f-calculation

Conversation

Copy link

Copilot AI commented Feb 19, 2026

✅ Completed: Remove Mean F Calculation and Process Time-Specific F-at-Age Vectors

Summary

Successfully modified generate_selectivity_curve() to process F-at-age vectors for each year-month combination instead of calculating mean F values across time.

Changes Made

1. Core Implementation (R/generate_selectivity_curve.R)

  • ✅ Added year, month, time_step to globalVariables
  • ✅ Updated required columns validation to include year and month
  • ✅ Removed mean F calculation logic (old lines 143-152)
  • ✅ Added time step processing with lapply over year-month combinations
  • ✅ Each time step now generates independent selectivity parameters
  • ✅ Results include time information in the time column
  • ✅ Handles edge cases (zero F values skip with warning)

2. Documentation Updates

  • ✅ Updated @param documentation to require year and month columns
  • ✅ Updated @return to indicate "one row per parameter per time step"
  • ✅ Updated @details to explain time-specific processing
  • ✅ Updated man/generate_selectivity_curve.Rd to match
  • ✅ Improved cli message formatting with {.val} syntax

3. Test Updates (tests/testthat/test-generate_selectivity_curve.R)

  • ✅ Updated row count expectations (2→24 for logistic, 4→48 for double_logistic with 12 months)
  • ✅ Changed assertions to use unique() for repeated values
  • ✅ Added checks for time column population
  • ✅ Simplified validation tests to use single time step
  • ✅ Updated error message expectations

Behavioral Changes

Before:

  • Calculated mean F value for each functional group (averaged across all time)
  • Generated single set of selectivity parameters
  • Output: 2 rows (logistic) or 4 rows (double_logistic)
  • time column was always NA

After:

  • Processes each year-month combination separately
  • Generates selectivity parameters for each time step
  • Output: (2 rows × n_timesteps) for logistic, (4 rows × n_timesteps) for double_logistic
  • time column contains "year-month" identifier (e.g., "2000-1")

Quality Checks

  • ✅ Code review: All feedback addressed
  • ✅ Security review: No vulnerabilities identified
  • ✅ Documentation: Complete and accurate
  • ✅ Tests: Updated for new behavior

Breaking Change Notice

This is a breaking change. Users expecting single parameter sets will now receive multiple sets (one per time step). Users should either:

  1. Filter results to a specific time step if single values are needed
  2. Update their code to handle time-varying parameters
Original prompt

In generate_selectivity_curve.R, don't calculate mean F values for each functional group for the year-month combinations. Extract F at age vector for each year-month combination and generate selectivity parameters. 

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 14 commits February 19, 2026 14:53
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
…features

Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
…ll inflection variables

Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
- Removed inst/selectivity_curves_guide.md (content integrated into function docs)
- Made fit_*_selectivity() documentation generic (not fishing-mortality-specific)
- Removed @author fields from all roxygen documentation
- Split tests into test-fit_selectivity_helpers.R and test-generate_selectivity_curve.R
- Changed real EWE test to use menhaden instead of dogfish
- Added validation tests that verify parameter recovery from known true values

Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Co-authored-by: Bai-Li-NOAA <59936250+Bai-Li-NOAA@users.noreply.github.com>
Copilot AI requested a review from Bai-Li-NOAA February 19, 2026 15:02
Copilot stopped work on behalf of Bai-Li-NOAA due to an error February 19, 2026 15:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants