8000 Merge pull request #28424 from charris/backport-28421 · numpy/numpy@d6580bc · GitHub
[go: up one dir, main page]

Skip to content

Commit d6580bc

Browse files
authored
Merge pull request #28424 from charris/backport-28421
BUG: skip legacy dtype multithreaded test on 32 bit runners
2 parents 747bd10 + 3b6288c commit d6580bc

File tree

8 files changed

+24
-29
lines changed

8 files changed

+24
-29
lines changed

numpy/_core/tests/test_array_coercion.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
from numpy._core._rational_tests import rational
1515

1616
from numpy.testing import (
17-
assert_array_equal, assert_warns, IS_PYPY)
17+
assert_array_equal, assert_warns, IS_PYPY, IS_64BIT
18+
)
1819

1920

2021
def arraylikes():
@@ -716,8 +717,7 @@ def __array__(self, dtype=None, copy=None):
716717
arr = np.array([ArrayLike])
717718
assert arr[0] is ArrayLike
718719

719-
@pytest.mark.skipif(
720-
np.dtype(np.intp).itemsize < 8, reason="Needs 64bit platform")
720+
@pytest.mark.skipif(not IS_64BIT, reason="Needs 64bit platform")
721721
def test_too_large_array_error_paths(self):
722722
"""Test the error paths, including for memory leaks"""
723723
arr = np.array(0, dtype="uint8")

numpy/_core/tests/test_multiarray.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
assert_array_equal, assert_raises_regex, assert_array_almost_equal,
3131
assert_allclose, IS_PYPY, IS_WASM, IS_PYSTON, HAS_REFCOUNT,
3232
assert_array_less, runstring, temppath, suppress_warnings, break_cycles,
33-
check_support_sve, assert_array_compare,
33+
check_support_sve, assert_array_compare, IS_64BIT
3434
)
3535
from numpy.testing._private.utils import requires_memory, _no_tracing
3636
from numpy._core.tests._locales import CommaDecimalPointLocale
@@ -983,7 +983,7 @@ def test_too_big_error(self):
983983
assert_raises(ValueError, np.zeros, shape, dtype=np.int8)
984984
assert_raises(ValueError, np.ones, shape, dtype=np.int8)
985985

986-
@pytest.mark.skipif(np.dtype(np.intp).itemsize != 8,
986+
@pytest.mark.skipif(not IS_64BIT,
987987
reason="malloc may not fail on 32 bit systems")
988988
def test_malloc_fails(self):
989989
# This test is guaranteed to fail due to a too large allocation

numpy/_core/tests/test_multithreading.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
import pytest
77

8-
from numpy.testing import IS_WASM
8+
from numpy.testing import IS_WASM, IS_64BIT
99
from numpy.testing._private.utils import run_threaded
1010
from numpy._core import _rational_tests
1111

@@ -257,20 +257,16 @@ def func(arr):
257257
f.result()
258258

259259

260+
@pytest.mark.skipif(
261+
not IS_64BIT,
262+
reason="Sometimes causes failures or crashes due to OOM on 32 bit runners"
263+
)
260264
def test_legacy_usertype_cast_init_thread_safety():
261265
def closure(b):
262266
b.wait()
263267
np.full((10, 10), 1, _rational_tests.rational)
264268

265-
try:
266-
run_threaded(closure, 250, pass_barrier=True)
267-
except RuntimeError:
268-
# The 32 bit linux runner will trigger this with 250 threads. I can
269-
# trigger it on my Linux laptop with 500 threads but the CI runner is
270-
# more resource-constrained.
271-
# Reducing the number of threads means the test doesn't trigger the
272-
# bug. Better to skip on some platforms than add a useless test.
273-
pytest.skip("Couldn't spawn enough threads to run the test")
269+
run_threaded(closure, 250, pass_barrier=True)
274270

275271
@pytest.mark.parametrize("dtype", [bool, int, float])
276272
def test_nonzero(dtype):

numpy/_core/tests/test_regression.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
assert_, assert_equal, IS_PYPY, assert_almost_equal,
1515
assert_array_equal, assert_array_almost_equal, assert_raises,
1616
assert_raises_regex, assert_warns, suppress_warnings,
17-
_assert_valid_refcount, HAS_REFCOUNT, IS_PYSTON, IS_WASM
17+
_assert_valid_refcount, HAS_REFCOUNT, IS_PYSTON, IS_WASM,
18+
IS_64BIT,
1819
)
1920
from numpy.testing._private.utils import _no_tracing, requires_memory
2021
from numpy._utils import asbytes, asunicode
@@ -2265,7 +2266,7 @@ def test_void_compare_segfault(self):
22652266
def test_reshape_size_overflow(self):
22662267
# gh-7455
22672268
a = np.ones(20)[::2]
2268-
if np.dtype(np.intp).itemsize == 8:
2269+
if IS_64BIT:
22692270
# 64 bit. The following are the prime factors of 2**63 + 5,
22702271
# plus a leading 2, so when multiplied together as int64,
22712272
# the result overflows to a total size of 10.

numpy/f2py/tests/test_return_real.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import platform
22
import pytest
3-
import numpy as np
43

54
from numpy import array
5+
from numpy.testing import IS_64BIT
66
from . import util
77

88

@@ -53,8 +53,7 @@ def check_function(self, t, tname):
5353
"but not when run in isolation",
5454
)
5555
@pytest.mark.skipif(
56-
np.dtype(np.intp).itemsize < 8,
57-
reason="32-bit builds are buggy"
56+
not IS_64BIT, reason="32-bit builds are buggy"
5857
)
5958
class TestCReturnReal(TestReturnReal):
6059
suffix = ".pyf"

numpy/f2py/tests/test_semicolon_split.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import platform
22
import pytest
3-
import numpy as np
3+
4+
from numpy.testing import IS_64BIT
45

56
from . import util
67

@@ -11,8 +12,7 @@
1112
"but not when run in isolation",
1213
)
1314
@pytest.mark.skipif(
14-
np.dtype(np.intp).itemsize < 8,
15-
reason="32-bit builds are buggy"
15+
not IS_64BIT, reason="32-bit builds are buggy"
1616
)
1717
class TestMultiline(util.F2PyTest):
1818
suffix = ".pyf"
@@ -44,8 +44,7 @@ def test_multiline(self):
4444
"but not when run in isolation",
4545
)
4646
@pytest.mark.skipif(
47-
np.dtype(np.intp).itemsize < 8,
48-
reason="32-bit builds are buggy"
47+
not IS_64BIT, reason="32-bit builds are buggy"
4948
)
5049
@pytest.mark.slow
5150
class TestCallstatement(util.F2PyTest):

numpy/lib/tests/test_format.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@
283283
import numpy as np
284284
from numpy.testing import (
285285
assert_, assert_array_equal, assert_raises, assert_raises_regex,
286-
assert_warns, IS_PYPY, IS_WASM
286+
assert_warns, IS_PYPY, IS_WASM, IS_64BIT
287287
)
288288
from numpy.testing._private.utils import requires_memory
289289
from numpy.lib import format
@@ -927,8 +927,7 @@ def test_large_file_support(tmpdir):
927927

928928

929929
@pytest.mark.skipif(IS_PYPY, reason="flaky on PyPy")
930-
@pytest.mark.skipif(np.dtype(np.intp).itemsize < 8,
931-
reason="test requires 64-bit system")
930+
@pytest.mark.skipif(not IS_64BIT, reason="test requires 64-bit system")
932931
@pytest.mark.slow
933932
@requires_memory(free_bytes=2 * 2**30)
934933
def test_large_archive(tmpdir):

numpy/testing/_private/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
'HAS_REFCOUNT', "IS_WASM", 'suppress_warnings', 'assert_array_compare',
4747
'assert_no_gc_cycles', 'break_cycles', 'HAS_LAPACK64', 'IS_PYSTON',
4848
'IS_MUSL', 'check_support_sve', 'NOGIL_BUILD',
49-
'IS_EDITABLE', 'IS_INSTALLED', 'NUMPY_ROOT', 'run_threaded',
49+
'IS_EDITABLE', 'IS_INSTALLED', 'NUMPY_ROOT', 'run_threaded', 'IS_64BIT',
5050
]
5151

5252

@@ -105,6 +105,7 @@ class KnownFailureException(Exception):
105105
IS_MUSL = True
106106

107107
NOGIL_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
108+
IS_64BIT = np.dtype(np.intp).itemsize == 8
108109

109110
def assert_(val, msg=''):
110111
"""

0 commit comments

Comments
 (0)
0