Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 444c98e

Browse files
authored
BUG,TST: Fix condition for whether long double is “IBM double double”. (#31375)
1 parent 9314c23 commit 444c98e

5 files changed

Lines changed: 17 additions & 9 deletions

File tree

numpy/_core/tests/test_scalar_methods.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"""
44
import fractions
55
import inspect
6-
import platform
76
import sys
87
import types
98
from typing import Any, Literal
@@ -13,6 +12,7 @@
1312
import numpy as np
1413
from numpy._core import sctypes
1514
from numpy.testing import assert_equal, assert_raises
15+
from numpy.testing._private.utils import LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE
1616

1717

1818
class TestAsIntegerRatio:
@@ -87,7 +87,7 @@ def test_against_known_values(self):
8787
np.finfo(np.double) == np.finfo(np.longdouble),
8888
reason="long double is same as double"),
8989
pytest.mark.skipif(
90-
platform.machine().startswith("ppc"),
90+
LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
9191
reason="IBM double double"),
9292
]
9393
)

numpy/_core/tests/test_scalarmath.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
assert_raises,
2424
check_support_sve,
2525
)
26+
from numpy.testing._private.utils import LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE
2627

2728
types = [np.bool, np.byte, np.ubyte, np.short, np.ushort, np.intc, np.uintc,
2829
np.int_, np.uint, np.longlong, np.ulonglong,
@@ -521,7 +522,7 @@ def test_int_from_infinite_longdouble(self):
521522

522523
@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
523524
reason="long double is same as double")
524-
@pytest.mark.skipif(platform.machine().startswith("ppc"),
525+
@pytest.mark.skipif(LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
525526
reason="IBM double double")
526527
def test_int_from_huge_longdouble(self):
527528
# Produce a longdouble that would overflow a double,

numpy/_core/tests/test_scalarprint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
""" Test printing of scalar types.
22
33
"""
4-
import platform
54

65
import pytest
76

87
import numpy as np
98
from numpy.testing import IS_MUSL, assert_, assert_equal, assert_raises
9+
from numpy.testing._private.utils import LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE
1010

1111

1212
class TestRealScalars:
@@ -329,8 +329,8 @@ def test_dragon4_scientific_interface(self, tp):
329329
assert_equal(fsci(tp('1.0'), unique=False, precision=4),
330330
"1.0000e+00")
331331

332-
@pytest.mark.skipif(not platform.machine().startswith("ppc64"),
333-
reason="only applies to ppc float128 values")
332+
@pytest.mark.skipif(not LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
333+
reason="only applies to ppc double-double values")
334334
def test_ppc64_ibm_double_double128(self):
335335
# check that the precision decreases once we get into the subnormal
336336
# range. Unlike float64, this starts around 1e-292 instead of 1e-308,

numpy/_core/tests/test_umath.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@
3131
assert_raises,
3232
assert_raises_regex,
3333
)
34-
from numpy.testing._private.utils import _glibc_older_than
34+
from numpy.testing._private.utils import (
35+
LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
36+
_glibc_older_than,
37+
)
3538

3639
UFUNCS = [obj for obj in np._core.umath.__dict__.values()
3740
if isinstance(obj, np.ufunc)]
@@ -4808,7 +4811,7 @@ def test_nextafterf():
48084811

48094812
@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
48104813
reason="long double is same as double")
4811-
@pytest.mark.xfail(condition=platform.machine().startswith("ppc64"),
4814+
@pytest.mark.xfail(condition=LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
48124815
reason="IBM double double")
48134816
def test_nextafterl():
48144817
return _test_nextafter(np.longdouble)
@@ -4869,7 +4872,7 @@ def test_spacingf():
48694872

48704873
@pytest.mark.skipif(np.finfo(np.double) == np.finfo(np.longdouble),
48714874
reason="long double is same as double")
4872-
@pytest.mark.xfail(condition=platform.machine().startswith("ppc64"),
4875+
@pytest.mark.xfail(condition=LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE,
48734876
reason="IBM double double")
48744877
def test_spacingl():
48754878
return _test_spacing(np.longdouble)

numpy/testing/_private/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ class KnownFailureException(Exception):
107107
NOGIL_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
108108
IS_64BIT = np.dtype(np.intp).itemsize == 8
109109

110+
LONG_DOUBLE_IS_IBM_DOUBLE_DOUBLE = (platform.machine().startswith("ppc")
111+
and str(np.finfo(np.longdouble).max)
112+
== "1.79769313486231580793728971405301e+308")
113+
110114
def assert_(val, msg=''):
111115
"""
112116
Assert that works in release mode.

0 commit comments

Comments
 (0)