diff options
| author | Tyler Reddy <tyler.je.reddy@gmail.com> | 2019-05-01 16:24:05 -0700 |
|---|---|---|
| committer | Tyler Reddy <tyler.je.reddy@gmail.com> | 2019-05-01 18:40:51 -0700 |
| commit | dadfa82c768027fe2dd19ebcf08bb845d7ca3ae8 (patch) | |
| tree | 2a918b4bed492d28002d60d7f853d169f0029395 /numpy/core | |
| parent | a85ceabe6ade23bf4502ae3dd57eff89beedbfd8 (diff) | |
| download | numpy-dadfa82c768027fe2dd19ebcf08bb845d7ca3ae8.tar.gz | |
MAINT: more adjustments in PR 10723
* adjust test_longdouble_from_int to properly
handle platforms where np.longdouble and
np.double have roughly equivalent limits
Diffstat (limited to 'numpy/core')
| -rw-r--r-- | numpy/core/tests/test_longdouble.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/numpy/core/tests/test_longdouble.py b/numpy/core/tests/test_longdouble.py index 66293e988..ee4197f8f 100644 --- a/numpy/core/tests/test_longdouble.py +++ b/numpy/core/tests/test_longdouble.py @@ -1,5 +1,6 @@ from __future__ import division, absolute_import, print_function +import warnings import pytest import numpy as np @@ -213,7 +214,18 @@ class TestCommaDecimalPointLocale(CommaDecimalPointLocale): def test_longdouble_from_int(int_val): # for issue gh-9968 str_val = str(int_val) - assert np.longdouble(int_val) == np.longdouble(str_val) + # we'll expect a RuntimeWarning on platforms + # with np.longdouble equivalent to np.double + # for large integer input + with warnings.catch_warnings(record=True) as w: + warnings.filterwarnings('always', '', RuntimeWarning) + # can be inf==inf on some platforms + assert np.longdouble(int_val) == np.longdouble(str_val) + # we can't directly compare the int and + # max longdouble value on all platforms + if np.allclose(np.finfo(np.longdouble).max, + np.finfo(np.double).max) and w: + assert w[0].category is RuntimeWarning @pytest.mark.parametrize("bool_val", [ True, False]) |
