TST: expand test coverage with edge cases and identity checks (#58)#140
Draft
MukundaKatta wants to merge 1 commit intonumpy:mainfrom
Draft
TST: expand test coverage with edge cases and identity checks (#58)#140MukundaKatta wants to merge 1 commit intonumpy:mainfrom
MukundaKatta wants to merge 1 commit intonumpy:mainfrom
Conversation
Adds numpy_financial/tests/test_coverage_expansion.py with 83 new tests focused on: * zero-rate edge cases for fv, pmt, pv, nper * error paths (npv shape errors, mirr size mismatch, irr no real solution, rate iterations exceeded on arrays) * vectorized vs scalar parity for fv, pmt, pv * analytical round-trip identities (pmt = ppmt + ipmt, npv(irr(x), x) = 0, fv/pv inversion) * _convert_when alias dispatch and ndarray pass-through * _irr_default_selection branches and custom selection_logic Coverage of numpy_financial/_financial.py rises from 97% to 99%. Refs numpygh-58.
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.
Summary
Refs #58. Expands test coverage with edge cases and identity checks. No library code touched.
Coverage delta
numpy_financial/_financial.py: 97% (6 missing) → 99% (2 missing). The 2 remaining lines are unreachable defensive branches.What's added
83 new test cases in 8 classes covering:
fv/pmt/pv/nper, infinite cashflows, scalar/0-d/array shapes, negative ratesnpvinvalid shape,mirrsize mismatch (both raise + nan-return),irrno-real-solution,rateiterations-exceeded array pathfv,pmt,pvpmt = ppmt + ipmt,npv(irr(x), x) = 0,fv/pvinverse relations_convert_whenalias coverage (9 aliases + ndarray pass-through + KeyError)_irr_default_selectionmixed-sign / same-sign / all-negative branches + customselection_logicinjectionFiles changed
numpy_financial/tests/test_coverage_expansion.py(new, 550 lines, 83 tests)Test plan
ruff formatandruff checkclean on the new file