Summary
make test runs green at 100% coverage, but the suite emits 2 RuntimeWarning: invalid value encountered in multiply from scipy. They originate from a stats computation reaching a scipy distribution call with a degenerate (NaN/empty/constant) input — a code path that is exercised but not explicitly handled or asserted.
Evidence
From make test output:
tests/test_jquantstats/test_migration/test_new_stats.py::test_annual_breakdown_metrics_match_summary_set
.venv/lib/python3.12/site-packages/scipy/stats/_distn_infrastructure.py:2334: RuntimeWarning: invalid value encountered in multiply
.venv/lib/python3.12/site-packages/scipy/stats/_distn_infrastructure.py:2335: RuntimeWarning: invalid value encountered in multiply
The triggering test is tests/test_jquantstats/test_migration/test_new_stats.py::test_annual_breakdown_metrics_match_summary_set. The relevant production code is in src/jquantstats/_stats/ (the annual-breakdown / summary stats path; see src/jquantstats/_stats/_reporting.py:704 annual_breakdown and the metric helpers it feeds). Note _montecarlo.py already wraps scipy calls in np.errstate(invalid="ignore", ...) (lines 146, 205) — this path does not.
Why it matters
A RuntimeWarning escaping the suite signals an untested edge case (degenerate input reaching scipy). Either the input should be guarded before the scipy call, or the condition is expected and should be made explicit rather than tolerated silently.
Proposed fix
- Identify the degenerate input (empty / constant / NaN return series) reaching the scipy distribution call.
- Either guard it explicitly before the call (preferred, mirroring the
np.errstate pattern in _montecarlo.py), or document it as expected and scope a targeted filterwarnings.
- Add an explicit test for the edge case.
Acceptance criteria
Filed from a /rhiza_quality assessment (coverage & depth subcategory, 9→10).
Summary
make testruns green at 100% coverage, but the suite emits 2RuntimeWarning: invalid value encountered in multiplyfrom scipy. They originate from a stats computation reaching a scipy distribution call with a degenerate (NaN/empty/constant) input — a code path that is exercised but not explicitly handled or asserted.Evidence
From
make testoutput:The triggering test is
tests/test_jquantstats/test_migration/test_new_stats.py::test_annual_breakdown_metrics_match_summary_set. The relevant production code is insrc/jquantstats/_stats/(the annual-breakdown / summary stats path; seesrc/jquantstats/_stats/_reporting.py:704annual_breakdownand the metric helpers it feeds). Note_montecarlo.pyalready wraps scipy calls innp.errstate(invalid="ignore", ...)(lines 146, 205) — this path does not.Why it matters
A
RuntimeWarningescaping the suite signals an untested edge case (degenerate input reaching scipy). Either the input should be guarded before the scipy call, or the condition is expected and should be made explicit rather than tolerated silently.Proposed fix
np.errstatepattern in_montecarlo.py), or document it as expected and scope a targetedfilterwarnings.Acceptance criteria
make testcompletes with zeroRuntimeWarnings.Filed from a
/rhiza_qualityassessment (coverage & depth subcategory, 9→10).