diff options
| author | Derek Homeier <dhomeie@gwdg.de> | 2022-06-17 18:39:44 +0200 |
|---|---|---|
| committer | Rohit Goswami <rog32@hi.is> | 2023-04-15 20:09:01 +0000 |
| commit | 0bee070d11ad4d14402f03f85650dbf5391735ca (patch) | |
| tree | 5a442b82ed99500ff03de98f373b929def72dd9b /numpy/f2py/tests | |
| parent | 7aa6d6dabe0b4b3e5bf378ec684778b46167cce4 (diff) | |
| download | numpy-0bee070d11ad4d14402f03f85650dbf5391735ca.tar.gz | |
DNM: test some more `selected_real_kind` results [skip azurepipelines]
Diffstat (limited to 'numpy/f2py/tests')
| -rw-r--r-- | numpy/f2py/tests/test_kind.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/numpy/f2py/tests/test_kind.py b/numpy/f2py/tests/test_kind.py index 5411ab45e..69b85aaad 100644 --- a/numpy/f2py/tests/test_kind.py +++ b/numpy/f2py/tests/test_kind.py @@ -1,5 +1,6 @@ import os import pytest +import platform from numpy.f2py.crackfortran import ( _selected_int_kind_func as selected_int_kind, @@ -11,8 +12,8 @@ from . import util class TestKind(util.F2PyTest): sources = [util.getpath("tests", "src", "kind", "foo.f90")] - def test_all(self): - selectedrealkind = self.module.selectedrealkind + def test_int(self): + """Test `int` kind_func for integers up to 10**40.""" selectedintkind = self.module.selectedintkind for i in range(40): @@ -20,7 +21,27 @@ class TestKind(util.F2PyTest): i ), f"selectedintkind({i}): expected {selected_int_kind(i)!r} but got {selectedintkind(i)!r}" - for i in range(40): + def test_real(self): + """ + Test (processor-dependent) `real` kind_func for real numbers + of up to 31 digits precision (extended/quadruple). + """ + selectedrealkind = self.module.selectedrealkind + + for i in range(32): + assert selectedrealkind(i) == selected_real_kind( + i + ), f"selectedrealkind({i}): expected {selected_real_kind(i)!r} but got {selectedrealkind(i)!r}" + + @pytest.mark.xfail(platform.machine().lower().startswith("ppc"), + reason="Some PowerPC may not support full IEEE 754 precision") + def test_quad_precision(self): + """ + Test kind_func for quadruple precision [`real(16)`] of 32+ digits . + """ + selectedrealkind = self.module.selectedrealkind + + for i in range(32, 40): assert selectedrealkind(i) == selected_real_kind( i ), f"selectedrealkind({i}): expected {selected_real_kind(i)!r} but got {selectedrealkind(i)!r}" |
