Skip to content

Commit

Permalink
Catch OverflowError
Browse files Browse the repository at this point in the history
Can happen in certain cases with basically valid but extreme input data
such as this example:

pmeirr, assetirr, df = (
    verbose_xpme(
        [date(2000, 1, 1), date(2000, 1, 2), date(2022, 1, 1)],
        [-1.0, 1.0],
        [1.0, 1.0, 1.0],
        [1.0, 2.0, 1.0],
    ),
)
  • Loading branch information
ymyke committed Mar 13, 2022
1 parent 6586ccb commit 15b05e2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/test_pypme.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ def test_xpme_hypothesis_driven(lists):
)
except ValueError as exc:
assert "least one cashflow" in str(exc) or "All prices" in str(exc)
except OverflowError as exc:
assert "Result too large" in str(exc)
else:
assert xnpv(df["PME", "CF"], pme_irr) == 0
assert xnpv(df["Asset", "CF"], asset_irr) == 0

0 comments on commit 15b05e2

Please sign in to comment.