summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorWarren Weckesser <warren.weckesser@gmail.com>2020-08-22 19:48:35 -0400
committerWarren Weckesser <warren.weckesser@gmail.com>2020-08-22 20:16:58 -0400
commitadccacf32ea8c159b2397a6053f4b97543ec08a7 (patch)
tree2c2b2261898a651005d0f1015d5c9961b77beb0f /numpy/lib
parent97f9fcb599fec377f35be647afdc2d5c2c6ba1f9 (diff)
downloadnumpy-adccacf32ea8c159b2397a6053f4b97543ec08a7.tar.gz
MAINT: lib: Change handling of the expired financial functions.
In a previous commit, the expired financial functions were removed from NumPy, and code was added to __init__.py using the module __getattr__ to raise a customized AttributeError on any attempt to reference the expired names in the numpy namespace. That change broke released versions astropy, which has code that imports the financial functions. astropy never calls the functions, so they never saw the deprecation warnings that have been in place since numpy 1.18. This means that attempting to use a released version of astropy with numpy 1.20 will cause astropy to crash with the custom AttributeError. In this commit, instead of raising an exception when one of the expired names is referenced, a warning is generated. If the function is *called*, an exception is raised.
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/tests/test_financial_expired.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/numpy/lib/tests/test_financial_expired.py b/numpy/lib/tests/test_financial_expired.py
index e1d05da0c..66bb08026 100644
--- a/numpy/lib/tests/test_financial_expired.py
+++ b/numpy/lib/tests/test_financial_expired.py
@@ -3,10 +3,11 @@ import pytest
import numpy as np
+@pytest.mark.skipif(sys.version_info[:2] < (3, 7),
+ reason="requires python 3.7 or higher")
def test_financial_expired():
- if sys.version_info[:2] >= (3, 7):
- match = 'NEP 32'
- else:
- match = None
- with pytest.raises(AttributeError, match=match):
- np.fv
+ match = 'NEP 32'
+ with pytest.warns(RuntimeWarning, match=match):
+ func = np.fv
+ with pytest.raises(RuntimeError, match=match):
+ func(1, 2, 3)