summaryrefslogtreecommitdiff
path: root/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py
diff options
context:
space:
mode:
authorblackhao <13851610112@163.com>2025-08-22 02:51:50 -0500
committerblackhao <13851610112@163.com>2025-08-22 02:51:50 -0500
commit4aab4087dc97906d0b9890035401175cdaab32d4 (patch)
tree4e2e9d88a711ec5b1cfa02e8ac72a55183b99123 /.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py
parentafa8f50d1d21c721dabcb31ad244610946ab65a3 (diff)
2.0
Diffstat (limited to '.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py')
-rw-r--r--.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py b/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py
new file mode 100644
index 0000000..ce223a5
--- /dev/null
+++ b/.venv/lib/python3.12/site-packages/numpy/f2py/tests/test_kind.py
@@ -0,0 +1,53 @@
+import platform
+import sys
+
+import pytest
+
+from numpy.f2py.crackfortran import (
+ _selected_int_kind_func as selected_int_kind,
+)
+from numpy.f2py.crackfortran import (
+ _selected_real_kind_func as selected_real_kind,
+)
+
+from . import util
+
+
+class TestKind(util.F2PyTest):
+ sources = [util.getpath("tests", "src", "kind", "foo.f90")]
+
+ @pytest.mark.skipif(sys.maxsize < 2 ** 31 + 1,
+ reason="Fails for 32 bit machines")
+ def test_int(self):
+ """Test `int` kind_func for integers up to 10**40."""
+ selectedintkind = self.module.selectedintkind
+
+ for i in range(40):
+ assert selectedintkind(i) == selected_int_kind(
+ i
+ ), f"selectedintkind({i}): expected {selected_int_kind(i)!r} but got {selectedintkind(i)!r}"
+
+ 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}"