Skip to content

Commit ce8c128

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Allow some numba errors on non-amd64, warn on non-x86
Specifying the exception type allows only explicit errors, not silently wrong answers Numba has been observed to give wrong answers on mipsel, and crash on armel (LLVM ERROR) and s390x (segfault). Author: Rebecca N. Palmer <[email protected]> Forwarded: no Gbp-Pq: Name numba_fail_32bit.patch
1 parent c6b03f9 commit ce8c128

File tree

8 files changed

+68
-2
lines changed

8 files changed

+68
-2
lines changed

pandas/compat/_optional.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
import sys
55
import types
66
import warnings
7+
import platform
8+
import re
9+
warn_numba_platform = "Non-x86 system detected, Numba may give wrong results or crash" if not bool(re.match('i.?86|x86',platform.uname()[4])) else False
710

811
from pandas.util._exceptions import find_stack_level
912

@@ -129,6 +132,8 @@ def import_optional_dependency(
129132
"""
130133

131134
assert errors in {"warn", "raise", "ignore"}
135+
if name=='numba' and warn_numba_platform:
136+
warnings.warn(warn_numba_platform)
132137

133138
package_name = INSTALL_MAPPING.get(name)
134139
install_name = package_name if package_name is not None else name

pandas/tests/groupby/aggregate/test_numba.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
1+
import sys
2+
13
import numpy as np
24
import pytest
35

6+
try:
7+
from numba.core.errors import UnsupportedParforsError,TypingError
8+
except ImportError:
9+
UnsupportedParforsError = ImportError
10+
TypingError = ImportError
11+
12+
from pandas.compat import is_platform_little_endian
13+
pytestmark = [pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False),pytest.mark.xfail(condition=sys.maxsize<2**33, raises=(UnsupportedParforsError,TypingError), reason="some Numba functionality is not available on 32 bit systems", strict=False)]
414
from pandas.errors import NumbaUtilError
515
import pandas.util._test_decorators as td
616

@@ -47,6 +57,7 @@ def incorrect_function(values, index):
4757

4858

4959
@td.skip_if_no("numba")
60+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
5061
@pytest.mark.filterwarnings("ignore")
5162
# Filter warnings when parallel=True and the function can't be parallelized by Numba
5263
@pytest.mark.parametrize("jit", [True, False])
@@ -76,6 +87,7 @@ def func_numba(values, index):
7687

7788

7889
@td.skip_if_no("numba")
90+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
7991
@pytest.mark.filterwarnings("ignore")
8092
# Filter warnings when parallel=True and the function can't be parallelized by Numba
8193
@pytest.mark.parametrize("jit", [True, False])

pandas/tests/groupby/test_numba.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,17 @@
77
Series,
88
)
99
import pandas._testing as tm
10-
10+
import sys
11+
try:
12+
from numba.core.errors import UnsupportedParforsError,TypingError
13+
except ImportError:
14+
UnsupportedParforsError = ImportError
15+
TypingError = ImportError
16+
from pandas.compat import is_platform_little_endian
17+
pytestmark = pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
1118

1219
@td.skip_if_no("numba")
20+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
1321
@pytest.mark.filterwarnings("ignore")
1422
# Filter warnings when parallel=True and the function can't be parallelized by Numba
1523
class TestEngine:

pandas/tests/groupby/test_timegrouper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import pandas._testing as tm
2424
from pandas.core.groupby.grouper import Grouper
2525
from pandas.core.groupby.ops import BinGrouper
26+
from pandas.compat import is_platform_little_endian
2627

2728

2829
@pytest.fixture
@@ -908,6 +909,7 @@ def test_groupby_apply_timegrouper_with_nat_apply_squeeze(
908909
tm.assert_series_equal(res, expected)
909910

910911
@td.skip_if_no("numba")
912+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
911913
def test_groupby_agg_numba_timegrouper_with_nat(
912914
self, groupby_with_truncated_bingrouper
913915
):

pandas/tests/groupby/transform/test_numba.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import sys
2+
13
import pytest
24

35
from pandas.errors import NumbaUtilError
@@ -9,6 +11,12 @@
911
option_context,
1012
)
1113
import pandas._testing as tm
14+
from pandas.compat import is_platform_little_endian
15+
try:
16+
from numba.core.errors import UnsupportedParforsError,TypingError
17+
except ImportError:
18+
UnsupportedParforsError = ImportError
19+
TypingError = ImportError
1220

1321

1422
@td.skip_if_no("numba")
@@ -44,6 +52,8 @@ def incorrect_function(values, index):
4452

4553

4654
@td.skip_if_no("numba")
55+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
56+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
4757
@pytest.mark.filterwarnings("ignore")
4858
# Filter warnings when parallel=True and the function can't be parallelized by Numba
4959
@pytest.mark.parametrize("jit", [True, False])
@@ -73,6 +83,8 @@ def func(values, index):
7383

7484

7585
@td.skip_if_no("numba")
86+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
87+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
7688
@pytest.mark.filterwarnings("ignore")
7789
# Filter warnings when parallel=True and the function can't be parallelized by Numba
7890
@pytest.mark.parametrize("jit", [True, False])
@@ -114,6 +126,7 @@ def func_2(values, index):
114126

115127

116128
@td.skip_if_no("numba")
129+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
117130
def test_use_global_config():
118131
def func_1(values, index):
119132
return values + 1
@@ -145,6 +158,7 @@ def test_multifunc_notimplimented(agg_func):
145158

146159

147160
@td.skip_if_no("numba")
161+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
148162
def test_args_not_cached():
149163
# GH 41647
150164
def sum_last(values, index, n):
@@ -162,6 +176,7 @@ def sum_last(values, index, n):
162176

163177

164178
@td.skip_if_no("numba")
179+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
165180
def test_index_data_correctly_passed():
166181
# GH 43133
167182
def f(values, index):
@@ -203,6 +218,8 @@ def func_kwargs(values, index):
203218

204219
@td.skip_if_no("numba")
205220
@pytest.mark.filterwarnings("ignore")
221+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
222+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
206223
def test_multiindex_one_key(nogil, parallel, nopython):
207224
def numba_func(values, index):
208225
return 1

pandas/tests/window/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import pytest
88

99
import pandas.util._test_decorators as td
10+
from pandas.compat import is_platform_little_endian
1011

1112
from pandas import (
1213
DataFrame,
@@ -98,7 +99,7 @@ def engine(request):
9899

99100
@pytest.fixture(
100101
params=[
101-
pytest.param(("numba", True), marks=td.skip_if_no("numba")),
102+
pytest.param(("numba", True), marks=[pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False),td.skip_if_no("numba")]),
102103
("cython", True),
103104
("cython", False),
104105
]

pandas/tests/window/test_numba.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@
2424
"'Windows fatal exception: stack overflow' "
2525
"and MacOS can timeout",
2626
)
27+
from pandas.compat import is_platform_little_endian
28+
import platform
29+
import sys
30+
try:
31+
from numba.core.errors import UnsupportedParforsError,TypingError
32+
except ImportError:
33+
UnsupportedParforsError = ImportError
34+
TypingError = ImportError
2735

2836

2937
@pytest.fixture(params=["single", "table"])
@@ -50,6 +58,8 @@ def arithmetic_numba_supported_operators(request):
5058

5159

5260
@td.skip_if_no("numba")
61+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
62+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
5363
@pytest.mark.filterwarnings("ignore")
5464
# Filter warnings when parallel=True and the function can't be parallelized by Numba
5565
class TestEngine:
@@ -134,6 +144,7 @@ def test_numba_vs_cython_expanding_methods(
134144
expected = getattr(expand, method)(engine="cython", **kwargs)
135145
tm.assert_equal(result, expected)
136146

147+
@pytest.mark.xfail(condition='mips' in platform.uname()[4].lower() and sys.maxsize<2**33, reason="Numba may give wrong answers on mipsel", strict=False)
137148
@pytest.mark.parametrize("jit", [True, False])
138149
def test_cache_apply(self, jit, nogil, parallel, nopython, step):
139150
# Test that the functions are cached correctly if we switch functions
@@ -227,6 +238,8 @@ def func(x):
227238

228239

229240
@td.skip_if_no("numba")
241+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
242+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
230243
class TestEWM:
231244
@pytest.mark.parametrize(
232245
"grouper", [lambda x: x, lambda x: x.groupby("A")], ids=["None", "groupby"]
@@ -310,6 +323,7 @@ def test_cython_vs_numba_times(self, grouper, nogil, parallel, nopython, ignore_
310323

311324

312325
@td.skip_if_no("numba")
326+
@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
313327
def test_use_global_config():
314328
def f(x):
315329
return np.mean(x) + 2
@@ -331,6 +345,7 @@ def test_invalid_kwargs_nopython():
331345

332346
@td.skip_if_no("numba")
333347
@pytest.mark.slow
348+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=(UnsupportedParforsError,TypingError), reason="some Numba functionality is not available on 32 bit systems", strict=False)
334349
@pytest.mark.filterwarnings("ignore")
335350
# Filter warnings when parallel=True and the function can't be parallelized by Numba
336351
class TestTableMethod:

pandas/tests/window/test_online.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222
"and MacOS can timeout",
2323
)
2424

25+
import sys
26+
try:
27+
from numba.core.errors import UnsupportedParforsError
28+
except ImportError:
29+
UnsupportedParforsError = ImportError
2530

2631
@td.skip_if_no("numba")
2732
@pytest.mark.filterwarnings("ignore")
@@ -37,6 +42,7 @@ def test_invalid_update(self):
3742
online_ewm.mean(update=df.head(1))
3843

3944
@pytest.mark.slow
45+
@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
4046
@pytest.mark.parametrize(
4147
"obj", [DataFrame({"a": range(5), "b": range(5)}), Series(range(5), name="foo")]
4248
)

0 commit comments

Comments
 (0)