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

Skip to content

Commit 9a2b8b4

Browse files
authored
Merge pull request #28421 from ngoldbaum/skip-32-bit
BUG: skip legacy dtype multithreaded test on 32 bit runners
2 parents d014c16 + c01cfd0 commit 9a2b8b4

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():
@@ -718,8 +719,7 @@ def __array__(self, dtype=None, copy=None):
718719
arr = np.array([ArrayLike])
719720
assert arr[0] is ArrayLike
720721

721-
@pytest.mark.skipif(
722-
np.dtype(np.intp).itemsize < 8, reason="Needs 64bit platform")
722+
@pytest.mark.skipif(not IS_64BIT, reason="Needs 64bit platform")
723723
def test_too_large_array_error_paths(self):
724724
"""Test the error paths, including for memory leaks"""
725725
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
@@ -978,7 +978,7 @@ def test_too_big_error(self):
978978
assert_raises(ValueError, np.zeros, shape, dtype=np.int8)
979979
assert_raises(ValueError, np.ones, shape, dtype=np.int8)
980980

981-
@pytest.mark.skipif(np.dtype(np.intp).itemsize != 8,
981+
@pytest.mark.skipif(not IS_64BIT,
982982
reason="malloc may not fail on 32 bit systems")
983983
def test_malloc_fails(self):
984984
# 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
@@ -2264,7 +2265,7 @@ def test_void_compare_segfault(self):
22642265
def test_reshape_size_overflow(self):
22652266
# gh-7455
22662267
a = np.ones(20)[::2]
2267-
if np.dtype(np.intp).itemsize == 8:
2268+
if IS_64BIT:
22682269
# 64 bit. The following are the prime factors of 2**63 + 5,
22692270
# plus a leading 2, so when multiplied together as int64,
22702271
# 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
@@ -926,8 +926,7 @@ def test_large_file_support(tmpdir):
926926

927927

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

numpy/testing/_private/utils.py

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

5151

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

106106
NOGIL_BUILD = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))
107+
IS_64BIT = np.dtype(np.intp).itemsize == 8
107108

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

0 commit comments

Comments
 (0)