Fix tests for IEEE long double on PPC

Resolves: RHEL-145970

Signed-off-by: Siteshwar Vashisht <svashisht@redhat.com>
This commit is contained in:
Siteshwar Vashisht 2026-06-11 13:44:44 +02:00
parent 082a394dd0
commit a9c9959bec
2 changed files with 135 additions and 1 deletions

View File

@ -0,0 +1,129 @@
diff --git a/numpy/core/tests/test_scalar_methods.py b/numpy/core/tests/test_scalar_methods.py
index 18a7bc8..a51e4f1 100644
--- a/numpy/core/tests/test_scalar_methods.py
+++ b/numpy/core/tests/test_scalar_methods.py
@@ -2,7 +2,6 @@
Test the scalar constructors, which also do type-coercion
"""
import fractions
-import platform
import types
from typing import Any, Type
@@ -10,6 +9,7 @@
import numpy as np
from numpy.testing import assert_equal, assert_raises, IS_MUSL
+from numpy.testing._private.utils import LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE
class TestAsIntegerRatio:
@@ -84,7 +84,7 @@ def test_against_known_values(self):
np.finfo(np.double) == np.finfo(np.longdouble),
reason="long double is same as double"),
pytest.mark.skipif(
- platform.machine().startswith("ppc"),
+ LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
reason="IBM double double"),
]
)
diff --git a/numpy/core/tests/test_scalarmath.py b/numpy/core/tests/test_scalarmath.py
index 9977c8b..f8e0a29 100644
--- a/numpy/core/tests/test_scalarmath.py
+++ b/numpy/core/tests/test_scalarmath.py
@@ -23,6 +23,8 @@
except TypeError:
USING_CLANG_CL = False
+from numpy.testing._private.utils import LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE
+
types = [np.bool_, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
np.int_, np.uint, np.longlong, np.ulonglong,
np.single, np.double, np.longdouble, np.csingle,
@@ -528,7 +530,7 @@ def test_int_from_infinite_longdouble___int__(self):
@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
reason="long double is same as double")
- @pytest.mark.skipif(platform.machine().startswith("ppc"),
+ @pytest.mark.skipif(LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
reason="IBM double double")
def test_int_from_huge_longdouble(self):
# Produce a longdouble that would overflow a double,
diff --git a/numpy/core/tests/test_scalarprint.py b/numpy/core/tests/test_scalarprint.py
index 98d1f4a..65cdeb3 100644
--- a/numpy/core/tests/test_scalarprint.py
+++ b/numpy/core/tests/test_scalarprint.py
@@ -2,13 +2,13 @@
"""
import code
-import platform
import pytest
import sys
from tempfile import TemporaryFile
import numpy as np
from numpy.testing import assert_, assert_equal, assert_raises, IS_MUSL
+from numpy.testing._private.utils import LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE
class TestRealScalars:
def test_str(self):
@@ -308,8 +308,8 @@ def test_dragon4_interface(self):
assert_equal(fpos(tp('1.'), trim='-'), "1")
assert_equal(fpos(tp('1.001'), precision=1, trim='-'), "1")
- @pytest.mark.skipif(not platform.machine().startswith("ppc64"),
- reason="only applies to ppc float128 values")
+ @pytest.mark.skipif(not LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
+ reason="only applies to ppc double-double values")
def test_ppc64_ibm_double_double128(self):
# check that the precision decreases once we get into the subnormal
# range. Unlike float64, this starts around 1e-292 instead of 1e-308,
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 963e740..ec59058 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -20,7 +20,10 @@
_gen_alignment_data, assert_array_almost_equal_nulp, IS_WASM, IS_MUSL,
IS_PYPY
)
-from numpy.testing._private.utils import _glibc_older_than
+from numpy.testing._private.utils import (
+ LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
+ _glibc_older_than,
+)
UFUNCS = [obj for obj in np.core.umath.__dict__.values()
if isinstance(obj, np.ufunc)]
@@ -4452,7 +4455,7 @@ def test_nextafterf():
@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
reason="long double is same as double")
-@pytest.mark.xfail(condition=platform.machine().startswith("ppc64"),
+@pytest.mark.xfail(condition=LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
reason="IBM double double")
def test_nextafterl():
return _test_nextafter(np.longdouble)
@@ -4491,7 +4494,7 @@ def test_spacingf():
@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
reason="long double is same as double")
-@pytest.mark.xfail(condition=platform.machine().startswith("ppc64"),
+@pytest.mark.xfail(condition=LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
reason="IBM double double")
def test_spacingl():
return _test_spacing(np.longdouble)
diff --git a/numpy/testing/_private/utils.py b/numpy/testing/_private/utils.py
index 28dd656..0a842a9 100644
--- a/numpy/testing/_private/utils.py
+++ b/numpy/testing/_private/utils.py
@@ -67,6 +67,9 @@ class KnownFailureException(Exception):
if 'musl' in _v:
IS_MUSL = True
+LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE = (platform.machine().startswith("ppc")
+ and str(np.finfo(np.longdouble).max)
+ == "1.79769313486231580793728971405301e+308")
def assert_(val, msg=''):
"""

View File

@ -20,7 +20,7 @@
Name: numpy
Version: 1.26.4
Release: 6%{?dist}
Release: 7%{?dist}
Epoch: 1
Summary: A fast multidimensional array facility for Python
@ -40,6 +40,8 @@ Patch0: f2py_test.patch
Patch4: replace-deprecated-ctypes.ARRAY.patch
# https://github.com/numpy/numpy/commit/e89ec589000e471f04c71b676c866baec05ecd7d
Patch5: fix-ppc64le-power10-test-failures.patch
# https://github.com/numpy/numpy/commit/444c98efc6ccddd15bfd313bbf5f69be2a5eb460
Patch6: ieee-long-double-ppc64-tests.patch
%description
@ -247,6 +249,9 @@ python3 runtests.py --no-build -- -ra -k 'not test_ppc64_ibm_double_double128 %{
%changelog
* Thu Jun 11 2026 Siteshwar Vashisht <svashisht@redhat.com> - 1:1.26.4-7
- Fix tests for IEEE long double on PPC (RHEL-145970)
* Tue Feb 03 2026 Lukáš Zaoral <lzaoral@redhat.com> - 1:1.26.4-6
- fix ppc64le test failures (RHEL-77878)