fix: honor rounding=0 in metrics helpers
FE
2d ago+29+29+01234567890123456789-3-3-0123456789
Summary
_mean, _stdev and _pstdev document rounding as the number of decimal places (default 3), but guard with if not rounding:, so the documented-valid value 0 was silently treated as "no rounding". _mean([1.4, 1.6], rounding=0) returned 1.5 instead of 2, and _pstdev([1,2,3], rounding=0) returned 0.816… instead of 1.
All three guards now use if rounding is None:. The default, None, and all other behavior are unchanged. This affects callers of the internal metrics helpers that pass rounding=0 to get integer results.
Validation
- Base source fails three new cases; with the fix
test_unstructured/metrics/test_utils.pyis 12 passed. ruff checkandruff format --checkon both changed files are clean.- The wider metrics suite cannot collect in this environment because an unrelated optional dependency (
unstructured_inference) is missing; the targeted file is unaffected.
Release note (optional)
Fixed the metrics helpers silently ignoring rounding=0.
Checklist
- Conventional commit title
- Regression tests added
- Focused test and lint checks run