From 88b6fd6c8935c6bcff52d67ffd52a26c2d2cbc3c Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sun, 5 May 2024 12:35:56 +1000 Subject: [PATCH] TST: Ignore warnings in MIRR fuzz test NumPy warns us of arithmetic overflow/underflow this only occurs when hypothesis generates extremely large values that are unlikely to ever occur in the real world. --- numpy_financial/tests/test_financial.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/numpy_financial/tests/test_financial.py b/numpy_financial/tests/test_financial.py index 656d4f1..7b95f3d 100644 --- a/numpy_financial/tests/test_financial.py +++ b/numpy_financial/tests/test_financial.py @@ -1,4 +1,5 @@ import math +import warnings from decimal import Decimal # Don't use 'import numpy as np', to avoid accidentally testing @@ -391,7 +392,13 @@ def test_mirr_no_real_solution_exception(self): ) def test_fuzz(self, values, finance_rate, reinvestment_rate): assume(finance_rate.size == reinvestment_rate.size) - npf.mirr(values, finance_rate, reinvestment_rate) + + # NumPy warns us of arithmetic overflow/underflow + # this only occurs when hypothesis generates extremely large values + # that are unlikely to ever occur in the real world. + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + npf.mirr(values, finance_rate, reinvestment_rate) @given( values=cashflow_array_like_strategy,