Raise test coverage to 99% and fix a constant-value regression - #54
Merged
Conversation
Coverage had fallen to 76% because most of the library was never
exercised: umath was at 54% with nearly every trigonometric, hyperbolic
and special function untested, and the operator overloads, the
distribution constructors and the printed reports were largely untouched.
The new tests take the package to 99%.
- test_umath_functions.py parametrizes all 39 unary functions plus the
stepwise, power and binary ones, checking each twice: once with a plain
float and once with an uncertain input. Reference values come from the
standard library, so a wrong derivative shows up as a mismatch instead
of agreeing with itself. umath goes from 54% to 100%.
- test_uncertain_function.py covers every operator, the derivative
accessors, and all four combinations of error_components.
- test_method_of_moments.py covers the standardization helpers, the
argument checks, the printed report and raw2central.
- test_distributions.py covers all eleven constructors against their
closed-form mean and variance, plus every parameter-validation path.
- test_uncertain_variable.py gains the setters and the plotting paths.
Writing them surfaced a real regression from the FORTRAN port: a constant
UncertainFunction has no input variables, so the kernel was handed
zero-length arrays and f2py raised
ValueError: unexpected array size: new_size=1, got array with arr_size=0
The Python loops it replaced simply iterated zero times, so
str(UncertainFunction(4.0)) used to work and had stopped. rawmoment,
variance_components and soerp_numeric now short-circuit when there are no
variables, which is also what to_uncertain_func needs for a plain number.
Coverage is now reported against src/soerp rather than site-packages.
The package carries a compiled extension so it cannot be imported from
the source tree, and without [tool.coverage.paths] the results do not line
up with the repository. matplotlib joins the test group so the optional
plotting path is exercised rather than skipped.
Two small things left uncovered deliberately: the PackageNotFoundError
fallback in __init__, which needs the package reloaded to reach, and the
defensive else branches in the error_components report, which cannot be
reached because the dictionaries are built from the same variable list
they are then looked up in.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: codex <267193182+codex@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: gemini-code-assist <gemini-code-assist@users.noreply.github.com>
Co-authored-by: Junie <junie@jetbrains.com>
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: kilocode-bot <github-actions@github.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Coverage had fallen to 76% because most of the library was never exercised: umath was at 54% with nearly every trigonometric, hyperbolic and special function untested, and the operator overloads, the distribution constructors and the printed reports were largely untouched. The new tests take the package to 99%.
Writing them surfaced a real regression from the FORTRAN port: a constant UncertainFunction has no input variables, so the kernel was handed zero-length arrays and f2py raised
The Python loops it replaced simply iterated zero times, so str(UncertainFunction(4.0)) used to work and had stopped. rawmoment, variance_components and soerp_numeric now short-circuit when there are no variables, which is also what to_uncertain_func needs for a plain number.
Coverage is now reported against src/soerp rather than site-packages. The package carries a compiled extension so it cannot be imported from the source tree, and without [tool.coverage.paths] the results do not line up with the repository. matplotlib joins the test group so the optional plotting path is exercised rather than skipped.
Two small things left uncovered deliberately: the PackageNotFoundError fallback in init, which needs the package reloaded to reach, and the defensive else branches in the error_components report, which cannot be reached because the dictionaries are built from the same variable list they are then looked up in.