Allow some numba errors on 32-bit
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Sun, 21 Apr 2024 12:50:13 +0000 (13:50 +0100)
committerRebecca N. Palmer <rebecca_palmer@zoho.com>
Sun, 21 Apr 2024 12:50:13 +0000 (13:50 +0100)
Specifying the exception type allows only explicit errors,
not silently wrong answers

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: no

Gbp-Pq: Name numba_fail_32bit.patch

pandas/tests/groupby/aggregate/test_numba.py
pandas/tests/groupby/conftest.py
pandas/tests/window/conftest.py
pandas/tests/window/test_numba.py

index ee694129f71183294dc780783d3b9ccdeae73bf4..1f7890ff8eada133330c0457eda9544c2a8ea39d 100644 (file)
@@ -11,6 +11,12 @@ from pandas import (
     option_context,
 )
 import pandas._testing as tm
+from pandas.compat import IS64
+try:
+    from numba.core.errors import UnsupportedParforsError, TypingError
+except ImportError:  # numba not installed
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
 
 pytestmark = pytest.mark.single_cpu
 
@@ -252,6 +258,12 @@ def test_multifunc_numba_vs_cython_series(agg_kwargs):
         ),
     ],
 )
+@pytest.mark.xfail(
+    condition=not IS64,
+    reason="parfors not available on 32-bit",
+    raises=UnsupportedParforsError,
+    strict=False,
+)
 def test_multifunc_numba_kwarg_propagation(data, agg_kwargs):
     pytest.importorskip("numba")
     labels = ["a", "a", "b", "b", "a"]
index 49fa9dc51f0d35a81fa7c71268b916c2b8b39efd..e755df7299cf9675a16e0100454f4600c035f205 100644 (file)
@@ -7,6 +7,11 @@ from pandas.core.groupby.base import (
     reduction_kernels,
     transformation_kernels,
 )
+from pandas.compat import IS64
+try:
+    from numba.core.errors import UnsupportedParforsError
+except ImportError:  # numba not installed
+    UnsupportedParforsError = ImportError
 
 
 @pytest.fixture(params=[True, False])
@@ -169,7 +174,22 @@ def groupby_func(request):
     return request.param
 
 
-@pytest.fixture(params=[True, False])
+# the xfail is because numba does not support this on 32-bit systems
+# https://github.com/numba/numba/blob/main/numba/parfors/parfors.py
+# strict=False because some tests are of error paths that
+# fail of something else before reaching this point
+@pytest.fixture(params=[
+                    pytest.param(
+                        True,
+                        marks=pytest.mark.xfail(
+                            condition=not IS64,
+                            reason="parfors not available on 32-bit",
+                            raises=UnsupportedParforsError,
+                            strict=False,
+                        )
+                    ),
+                    False,
+                ])
 def parallel(request):
     """parallel keyword argument for numba.jit"""
     return request.param
index 73ab470ab97a77a65001d62aa05be7d372fbc1f5..19faa3bd16ee8c8d5988855e5cb83af71f9e4533 100644 (file)
@@ -13,6 +13,12 @@ from pandas import (
     Series,
     bdate_range,
 )
+from pandas.compat import IS64
+try:
+    from numba.core.errors import UnsupportedParforsError, TypingError
+except ImportError:  # numba not installed
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
 
 
 @pytest.fixture(params=[True, False])
@@ -50,7 +56,22 @@ def min_periods(request):
     return request.param
 
 
-@pytest.fixture(params=[True, False])
+# the xfail is because numba does not support this on 32-bit systems
+# https://github.com/numba/numba/blob/main/numba/parfors/parfors.py
+# strict=False because some tests are of error paths that
+# fail of something else before reaching this point
+@pytest.fixture(params=[
+                    pytest.param(
+                        True,
+                        marks=pytest.mark.xfail(
+                            condition=not IS64,
+                            reason="parfors not available on 32-bit",
+                            raises=(UnsupportedParforsError, TypingError),
+                            strict=False,
+                        )
+                    ),
+                    False,
+                ])
 def parallel(request):
     """parallel keyword argument for numba.jit"""
     return request.param
index f5ef6a00e0b329eb8d31dfed73e4a3a132dd52bb..6422a9d34be18a58aa9bbe4a9a41aee78db1f85b 100644 (file)
@@ -5,7 +5,13 @@ from pandas.compat import (
     is_ci_environment,
     is_platform_mac,
     is_platform_windows,
+    IS64,
 )
+try:
+    from numba.core.errors import UnsupportedParforsError, TypingError
+except ImportError:  # numba not installed
+    UnsupportedParforsError = ImportError
+    TypingError = ImportError
 from pandas.errors import NumbaUtilError
 import pandas.util._test_decorators as td
 
@@ -199,6 +205,12 @@ class TestEngine:
         expected = DataFrame({"value": [2.0, 2.0, 2.0]})
         tm.assert_frame_equal(result, expected)
 
+    @pytest.mark.xfail(
+        condition=not IS64,
+        reason="parfors not available on 32-bit",
+        raises=UnsupportedParforsError,
+        strict=False,
+    )
     def test_dont_cache_engine_kwargs(self):
         # If the user passes a different set of engine_kwargs don't return the same
         # jitted function
@@ -339,6 +351,12 @@ class TestTableMethod:
                 f, engine="numba", raw=True
             )
 
+    @pytest.mark.xfail(
+        condition=not IS64,
+        reason="parfors not available on 32-bit",
+        raises=(UnsupportedParforsError, TypingError),
+        strict=False,
+    )
     def test_table_method_rolling_methods(
         self,
         axis,
@@ -421,6 +439,12 @@ class TestTableMethod:
         )
         tm.assert_frame_equal(result, expected)
 
+    @pytest.mark.xfail(
+        condition=not IS64,
+        reason="parfors not available on 32-bit",
+        raises=(UnsupportedParforsError, TypingError),
+        strict=False,
+    )
     def test_table_method_expanding_methods(
         self, axis, nogil, parallel, nopython, arithmetic_numba_supported_operators
     ):