Allow some numba errors on non-amd64, warn on non-x86
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Sun, 19 Feb 2023 11:01:48 +0000 (11:01 +0000)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sun, 19 Feb 2023 11:01:48 +0000 (11:01 +0000)
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 <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name numba_fail_32bit.patch

pandas/compat/_optional.py
pandas/tests/groupby/aggregate/test_numba.py
pandas/tests/groupby/test_numba.py
pandas/tests/groupby/test_timegrouper.py
pandas/tests/groupby/transform/test_numba.py
pandas/tests/window/conftest.py
pandas/tests/window/test_numba.py
pandas/tests/window/test_online.py

index 3caa92758dd529e0784a0c4dbbbaf6213c18bfef..9975e476ea6af8fdc18fb21e50d9855071d225c4 100644 (file)
@@ -4,6 +4,9 @@ import importlib
 import sys
 import types
 import warnings
+import platform
+import re
+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
 
 from pandas.util._exceptions import find_stack_level
 
@@ -129,6 +132,8 @@ def import_optional_dependency(
     """
 
     assert errors in {"warn", "raise", "ignore"}
+    if name=='numba' and warn_numba_platform:
+        warnings.warn(warn_numba_platform)
 
     package_name = INSTALL_MAPPING.get(name)
     install_name = package_name if package_name is not None else name
index 0b2fb56a0200608ef5b4841777caf09f0007e509..d64f18b5f79e75e6954e8a5f098499cf2060b4be 100644 (file)
@@ -1,6 +1,16 @@
+import sys
+
 import numpy as np
 import pytest
 
+try:
+    from numba.core.errors import UnsupportedParforsError,TypingError
+except ImportError:
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
+
+from pandas.compat import is_platform_little_endian
+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)]
 from pandas.errors import NumbaUtilError
 import pandas.util._test_decorators as td
 
@@ -47,6 +57,7 @@ def test_check_nopython_kwargs():
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 @pytest.mark.parametrize("jit", [True, False])
@@ -76,6 +87,7 @@ def test_numba_vs_cython(jit, pandas_obj, nogil, parallel, nopython):
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 @pytest.mark.parametrize("jit", [True, False])
index 4eb7b6a7b5beae2070d49f7b09d1611e9c495e3f..78660e2734828069e1b027ff553c4f5e9662986e 100644 (file)
@@ -7,9 +7,17 @@ from pandas import (
     Series,
 )
 import pandas._testing as tm
-
+import sys
+try:
+    from numba.core.errors import UnsupportedParforsError,TypingError
+except ImportError:
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
+from pandas.compat import is_platform_little_endian
+pytestmark = pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 class TestEngine:
index ae725cbb2b588c4fd052998dafeb465ecc653132..e40211e477f3349642f6f56fa76978de8ff8561e 100644 (file)
@@ -23,6 +23,7 @@ from pandas import (
 import pandas._testing as tm
 from pandas.core.groupby.grouper import Grouper
 from pandas.core.groupby.ops import BinGrouper
+from pandas.compat import is_platform_little_endian
 
 
 @pytest.fixture
@@ -908,6 +909,7 @@ class TestGroupBy:
         tm.assert_series_equal(res, expected)
 
     @td.skip_if_no("numba")
+    @pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
     def test_groupby_agg_numba_timegrouper_with_nat(
         self, groupby_with_truncated_bingrouper
     ):
index 2b70d7325a209405b0c2ef6228ce5a5b04382504..91beeed938e8a6e33060f1fabab20d1e65f6a175 100644 (file)
@@ -1,3 +1,5 @@
+import sys
+
 import pytest
 
 from pandas.errors import NumbaUtilError
@@ -9,6 +11,12 @@ from pandas import (
     option_context,
 )
 import pandas._testing as tm
+from pandas.compat import is_platform_little_endian
+try:
+    from numba.core.errors import UnsupportedParforsError,TypingError
+except ImportError:
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
 
 
 @td.skip_if_no("numba")
@@ -44,6 +52,8 @@ def test_check_nopython_kwargs():
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 @pytest.mark.parametrize("jit", [True, False])
@@ -73,6 +83,8 @@ def test_numba_vs_cython(jit, pandas_obj, nogil, parallel, nopython):
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 @pytest.mark.parametrize("jit", [True, False])
@@ -114,6 +126,7 @@ def test_cache(jit, pandas_obj, nogil, parallel, nopython):
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 def test_use_global_config():
     def func_1(values, index):
         return values + 1
@@ -145,6 +158,7 @@ def test_multifunc_notimplimented(agg_func):
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 def test_args_not_cached():
     # GH 41647
     def sum_last(values, index, n):
@@ -162,6 +176,7 @@ def test_args_not_cached():
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 def test_index_data_correctly_passed():
     # GH 43133
     def f(values, index):
@@ -203,6 +218,8 @@ def test_engine_kwargs_not_cached():
 
 @td.skip_if_no("numba")
 @pytest.mark.filterwarnings("ignore")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 def test_multiindex_one_key(nogil, parallel, nopython):
     def numba_func(values, index):
         return 1
index d05bb3d51bcdeb650d1381b7e42bb4dc58826f4b..22300147fa73048ed7590f61e88dcec4ce0468df 100644 (file)
@@ -7,6 +7,7 @@ import numpy as np
 import pytest
 
 import pandas.util._test_decorators as td
+from pandas.compat import is_platform_little_endian
 
 from pandas import (
     DataFrame,
@@ -98,7 +99,7 @@ def engine(request):
 
 @pytest.fixture(
     params=[
-        pytest.param(("numba", True), marks=td.skip_if_no("numba")),
+        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")]),
         ("cython", True),
         ("cython", False),
     ]
index 89e00af270a0209d8d8802137d3ec9dfd3d43db8..96cf765c4a9cfbbde845f567a24bb0765eff64a7 100644 (file)
@@ -24,6 +24,14 @@ pytestmark = pytest.mark.skipif(
     "'Windows fatal exception: stack overflow' "
     "and MacOS can timeout",
 )
+from pandas.compat import is_platform_little_endian
+import platform
+import sys
+try:
+    from numba.core.errors import UnsupportedParforsError,TypingError
+except ImportError:
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
 
 
 @pytest.fixture(params=["single", "table"])
@@ -50,6 +58,8 @@ def arithmetic_numba_supported_operators(request):
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 class TestEngine:
@@ -134,6 +144,7 @@ class TestEngine:
         expected = getattr(expand, method)(engine="cython", **kwargs)
         tm.assert_equal(result, expected)
 
+    @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)
     @pytest.mark.parametrize("jit", [True, False])
     def test_cache_apply(self, jit, nogil, parallel, nopython, step):
         # Test that the functions are cached correctly if we switch functions
@@ -227,6 +238,8 @@ class TestEngine:
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 class TestEWM:
     @pytest.mark.parametrize(
         "grouper", [lambda x: x, lambda x: x.groupby("A")], ids=["None", "groupby"]
@@ -310,6 +323,7 @@ class TestEWM:
 
 
 @td.skip_if_no("numba")
+@pytest.mark.xfail(condition=not is_platform_little_endian(), reason="Numba may crash on s390x", run=False, strict=False)
 def test_use_global_config():
     def f(x):
         return np.mean(x) + 2
@@ -331,6 +345,7 @@ def test_invalid_kwargs_nopython():
 
 @td.skip_if_no("numba")
 @pytest.mark.slow
+@pytest.mark.xfail(condition=sys.maxsize<2**33, raises=(UnsupportedParforsError,TypingError), reason="some Numba functionality is not available on 32 bit systems", strict=False)
 @pytest.mark.filterwarnings("ignore")
 # Filter warnings when parallel=True and the function can't be parallelized by Numba
 class TestTableMethod:
index 88f462869d8b65fb0021cd30c7b5f35d355e2625..2dc822279fcae09252a1d717eb8c009edfe90171 100644 (file)
@@ -22,6 +22,11 @@ pytestmark = pytest.mark.skipif(
     "and MacOS can timeout",
 )
 
+import sys
+try:
+    from numba.core.errors import UnsupportedParforsError
+except ImportError:
+    UnsupportedParforsError = ImportError
 
 @td.skip_if_no("numba")
 @pytest.mark.filterwarnings("ignore")
@@ -37,6 +42,7 @@ class TestEWM:
             online_ewm.mean(update=df.head(1))
 
     @pytest.mark.slow
+    @pytest.mark.xfail(condition=sys.maxsize<2**33, raises=UnsupportedParforsError, reason="some Numba functionality is not available on 32 bit systems", strict=False)
     @pytest.mark.parametrize(
         "obj", [DataFrame({"a": range(5), "b": range(5)}), Series(range(5), name="foo")]
     )