Conversation
- Implemented `NewtonRaphson` struct in `pure_math::analysis::roots`. - Implemented `RootFinder` trait for `NewtonRaphson` with numerical differentiation. - Added `find_root_with_derivative` method to `NewtonRaphson` for analytical derivatives. - Refactored `epidemiology::analytics::calculate_final_size` to use `NewtonRaphson`. - Updated `EpidemiologyError` to include `AnalysisError`. - Added unit tests for `NewtonRaphson` and verified existing tests. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
Combined multiline `find_root_with_derivative` call into a single line to satisfy `rustfmt`. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Fixed `clippy::doc_overindented_list_items` violation by reducing indentation of continuation line in `find_root_with_derivative` doc comment. Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
🔧 The Violation:
The
calculate_final_sizefunction inmath_explorer/src/epidemiology/analytics.rscontained a hardcoded implementation of the Newton-Raphson method, violating DRY (logic duplication of a standard algorithm) and SRP (mixing domain logic with numerical solving). It also used string-based error handling.🛠️ The Fix:
NewtonRaphsonsolver inmath_explorer/src/pure_math/analysis/roots.rs. This struct implements the existingRootFindertrait (using numerical differentiation) and exposes a specializedfind_root_with_derivativemethod for high-precision use cases.calculate_final_sizeto use the newNewtonRaphsoncomponent, injecting the analytical derivative of the final size equation.EpidemiologyErrorto wrapAnalysisError, moving away from stringly-typed errors.📉 Debt Reduction:
🧪 Integrity:
NewtonRaphsoncovering linear, quadratic, and bounded scenarios.test_final_size_high_r0passes with the new implementation.PR created automatically by Jules for task 18224543845005302773 started by @fderuiter