Skip to content

Reduce redundancies and fix dead test coverage in functionality_tests.jl#278

Draft
thorek1 with Copilot wants to merge 2 commits into
mainfrom
copilot/improve-script-structure-again
Draft

Reduce redundancies and fix dead test coverage in functionality_tests.jl#278
thorek1 with Copilot wants to merge 2 commits into
mainfrom
copilot/improve-script-structure-again

Conversation

Copilot AI commented Mar 3, 2026

Copy link
Copy Markdown
Contributor

functionality_tests.jl had significant structural redundancy and three silently-disabled @test assertions due to a typo. This PR extracts helpers to eliminate repeated boilerplate and re-enables the dead test code.

Structural improvements

  • make_params(m, old_params) — replaces two near-identical 7-element array constructions for params/params2
  • make_conditions_and_shocks(m, algorithm; condition_values, level_differences, shock_values) — replaces three ~80-line duplicate blocks that built conditions, conditions_lvl, and shocks for conditional forecast tests; parameterized with descriptive keyword args so callers express intent clearly
# plot_conditional_forecast: varied values for smoke testing
conditions2, conditions_lvl2, _ = make_conditions_and_shocks(m2, algorithm)
conditions, conditions_lvl, shocks = make_conditions_and_shocks(m, algorithm)

# get_conditional_forecast: uniform values so deviation == level constraint
# and @test isapprox(cond_fcst, cond_fcst_lvl) holds
conditions, conditions_lvl, shocks = make_conditions_and_shocks(m, algorithm,
    condition_values  = [(.01, .02), (.01, .02), (.01, .02), (.01, .02)],
    level_differences = [(.01, .02), (.01, .02)],
    shock_values = (.1, .1, .1, .1))

Net change: −135 lines (93 added, 228 removed).

Test coverage gaps fixed

Three Zygote covariance gradient @test assertions were never executing due to algorithm == :first_order_ (trailing underscore — always false). Fixed to algorithm == :first_order, re-enabling:

  • @test isapprox(deriv5_zyg[1], deriv5_fin[1], rtol = 1e-4) — Zygote vs finite-diff on initial covariance Jacobian
  • @test isapprox(deriv5_zyg[1], DERIV5_zyg[1], rtol = 1e-4) — Zygote consistency across solver algorithm variants
Original prompt

find some improvements on the script structure. reduce redundancies in coding. determine gaps in test coverage

The user has attached the following file paths as relevant context:

  • test/functionality_tests.jl
  • .github/copilot-instructions.md
  • AGENTS.md
  • CLAUDE.md

Created from VS Code.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: thorek1 <13523097+thorek1@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor script structure and reduce coding redundancies Reduce redundancies and fix dead test coverage in functionality_tests.jl Mar 3, 2026
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