fixes to d2 - #94
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
It introduces significant behavioral/API default changes (baseline shifting and d2_threshold) that need clearer configurability/documentation, and there are test-comment accuracy/provenance issues to resolve.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR updates Moteki–Kondo normalized derivative method computations to use consistent baseline handling (shifting each event’s scattering signal so its minimum is zero), adjusts sigma-estimation acceptance threshold defaults, and updates test parameters/tolerances to match the new behavior.
Changes:
- Added
_baseline_to_zeroand applied it when extracting per-eventSfor Moteki–Kondo tau/d²/sigma computations. - Changed
compute_sigma_moteki_kondodefaultd2_thresholdfrom80000.0to20.0. - Updated test coefficients (
A1,A2,A3) and relaxed several test tolerances; refined test comments.
File summaries
| File | Description |
|---|---|
pysp2/util/normalized_derivative_method.py |
Adds baseline-shift helper, applies it in Moteki–Kondo routines, and changes default d2_threshold. |
tests/test_ndm.py |
Updates Moteki–Kondo test parameters/tolerances and related commentary. |
tests/test_vis.py |
Updates visualization tests’ Moteki–Kondo parameters and adds explanatory comments. |
Review details
- Files reviewed: 3/6 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This pull request updates the baseline handling and parameterization for the Moteki-Kondo normalized derivative method, improves consistency with related methods, and refines test tolerances and parameters for better accuracy and reproducibility. The most important changes are grouped below:
Core logic improvements
_baseline_to_zeroto shift event signals so their minimum is zero, ensuring baseline handling matches thecentral_differencemethod. This function is now used throughout the Moteki-Kondo computation functions (_tau_hat_for_one_event,compute_d2_moteki_kondo, andcompute_sigma_moteki_kondo). [1] [2] [3] [4]Parameter and threshold adjustments
d2_thresholdparameter incompute_sigma_moteki_kondofrom 80000.0 to 20.0, likely to better reflect the expected range for the updated baseline handling.Test parameter updates
A1,A2, andA3coefficients used in test cases to new values optimized for the current dataset, replacing the previous scaling approach. This affects tests in bothtest_ndm.pyandtest_vis.py. [1] [2] [3] [4]Test tolerance refinements