Skip to content

Commit

Permalink
TST: disable longdouble string/print tests on Linux aarch64
Browse files Browse the repository at this point in the history
  • Loading branch information
rgommers committed Jun 18, 2023
1 parent 107f116 commit 74f372a
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 9 deletions.
6 changes: 5 additions & 1 deletion numpy/core/tests/test_arrayprint.py
@@ -1,3 +1,4 @@
import platform
import sys
import gc
from hypothesis import given
Expand Down Expand Up @@ -164,7 +165,10 @@ class TestComplexArray:
def test_str(self):
rvals = [0, 1, -1, np.inf, -np.inf, np.nan]
cvals = [complex(rp, ip) for rp in rvals for ip in rvals]
dtypes = [np.complex64, np.cdouble, np.clongdouble]
if platform.machine() == 'aarch64': # see gh-23974
dtypes = [np.complex64, np.cdouble]
else:
dtypes = [np.complex64, np.cdouble, np.clongdouble]
actual = [str(np.array([c], dt)) for c in cvals for dt in dtypes]
wanted = [
'[0.+0.j]', '[0.+0.j]', '[0.+0.j]',
Expand Down
20 changes: 14 additions & 6 deletions numpy/core/tests/test_print.py
@@ -1,4 +1,5 @@
import sys
import platform

import pytest

Expand All @@ -12,7 +13,14 @@
_REF = {np.inf: 'inf', -np.inf: '-inf', np.nan: 'nan'}


@pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble])
# longdouble printing issue on aarch64, see gh-23974
if platform.machine() == 'aarch64':
_real_dtypes = [np.float32, np.double]
_complex_dtypes = [np.complex64, np.cdouble]
else:
_real_dtypes = [np.float32, np.double, np.longdouble]
_complex_dtypes = [np.complex64, np.cdouble, np.clongdouble]
@pytest.mark.parametrize('tp', _real_dtypes)
def test_float_types(tp):
""" Check formatting.
Expand All @@ -34,7 +42,7 @@ def test_float_types(tp):
err_msg='Failed str formatting for type %s' % tp)


@pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble])
@pytest.mark.parametrize('tp', _real_dtypes)
def test_nan_inf_float(tp):
""" Check formatting of nan & inf.
Expand All @@ -48,7 +56,7 @@ def test_nan_inf_float(tp):
err_msg='Failed str formatting for type %s' % tp)


@pytest.mark.parametrize('tp', [np.complex64, np.cdouble, np.clongdouble])
@pytest.mark.parametrize('tp', _complex_dtypes)
def test_complex_types(tp):
"""Check formatting of complex types.
Expand All @@ -74,7 +82,7 @@ def test_complex_types(tp):
err_msg='Failed str formatting for type %s' % tp)


@pytest.mark.parametrize('dtype', [np.complex64, np.cdouble, np.clongdouble])
@pytest.mark.parametrize('dtype', _complex_dtypes)
def test_complex_inf_nan(dtype):
"""Check inf/nan formatting of complex types."""
TESTS = {
Expand Down Expand Up @@ -119,7 +127,7 @@ def _test_redirected_print(x, tp, ref=None):
err_msg='print failed for type%s' % tp)


@pytest.mark.parametrize('tp', [np.float32, np.double, np.longdouble])
@pytest.mark.parametrize('tp', _real_dtypes)
def test_float_type_print(tp):
"""Check formatting when using print """
for x in [0, 1, -1, 1e20]:
Expand All @@ -135,7 +143,7 @@ def test_float_type_print(tp):
_test_redirected_print(float(1e16), tp, ref)


@pytest.mark.parametrize('tp', [np.complex64, np.cdouble, np.clongdouble])
@pytest.mark.parametrize('tp', _complex_dtypes)
def test_complex_type_print(tp):
"""Check formatting when using print """
# We do not create complex with inf/nan directly because the feature is
Expand Down
10 changes: 8 additions & 2 deletions numpy/core/tests/test_scalarprint.py
Expand Up @@ -13,7 +13,11 @@
class TestRealScalars:
def test_str(self):
svals = [0.0, -0.0, 1, -1, np.inf, -np.inf, np.nan]
styps = [np.float16, np.float32, np.float64, np.longdouble]
# longdouble printing issue on aarch64, see gh-23974
if platform.machine() == 'aarch64':
styps = [np.float16, np.float32, np.float64]
else:
styps = [np.float16, np.float32, np.float64, np.longdouble]
wanted = [
['0.0', '0.0', '0.0', '0.0' ],
['-0.0', '-0.0', '-0.0', '-0.0'],
Expand Down Expand Up @@ -263,7 +267,9 @@ def test_dragon4(self):
def test_dragon4_interface(self):
tps = [np.float16, np.float32, np.float64]
# test is flaky for musllinux on np.float128
if hasattr(np, 'float128') and not IS_MUSL:
# also currently failing on Linux aarch64 with Meson (see gh-23974)
is_aarch64 = platform.machine() == 'aarch64'
if hasattr(np, 'float128') and not IS_MUSL and not is_aarch64:
tps.append(np.float128)

fpos = np.format_float_positional
Expand Down
4 changes: 4 additions & 0 deletions numpy/core/tests/test_strings.py
@@ -1,5 +1,6 @@
import pytest

import platform
import operator
import numpy as np

Expand Down Expand Up @@ -88,6 +89,9 @@ def test_string_comparisons_empty(op, ufunc, sym, dtypes):
@pytest.mark.parametrize("str_dt", ["S", "U"])
@pytest.mark.parametrize("float_dt", np.typecodes["AllFloat"])
def test_float_to_string_cast(str_dt, float_dt):
if platform.machine() == 'aarch64' and float_dt == 'g':
pytest.xfail("string repr issues with longdouble, see gh-23974")

float_dt = np.dtype(float_dt)
fi = np.finfo(float_dt)
arr = np.array([np.nan, np.inf, -np.inf, fi.max, fi.min], dtype=float_dt)
Expand Down

0 comments on commit 74f372a

Please sign in to comment.