Skip to content

REF: Remove Numba compat pre 0.50.1 #43266

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions pandas/core/util/numba_.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
from pandas.compat._optional import import_optional_dependency
from pandas.errors import NumbaUtilError

from pandas.util.version import Version

GLOBAL_USE_NUMBA: bool = False
NUMBA_FUNC_CACHE: dict[tuple[Callable, str], Callable] = {}

Expand Down Expand Up @@ -87,12 +85,7 @@ def jit_user_function(
"""
numba = import_optional_dependency("numba")

if Version(numba.__version__) >= Version("0.49.0"):
is_jitted = numba.extending.is_jitted(func)
else:
is_jitted = isinstance(func, numba.targets.registry.CPUDispatcher)

if is_jitted:
if numba.extending.is_jitted(func):
# Don't jit a user passed jitted function
numba_func = func
else:
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/frame/test_ufunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def test_alignment_deprecation():
tm.assert_frame_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_alignment_deprecation_many_inputs():
# https://github.com/pandas-dev/pandas/issues/39184
# test that the deprecation also works with > 2 inputs -> using a numba
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/groupby/aggregate/test_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pandas.core.util.numba_ import NUMBA_FUNC_CACHE


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prob could remove these individual skips and just skip the entire module if numba not installed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True. All */test_numba.py tests should require numba

def test_correct_function_signature():
def incorrect_function(x):
return sum(x) * 2.7
Expand All @@ -31,7 +31,7 @@ def incorrect_function(x):
data.groupby("key")["data"].agg(incorrect_function, engine="numba")


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_check_nopython_kwargs():
def incorrect_function(x, **kwargs):
return sum(x) * 2.7
Expand All @@ -47,7 +47,7 @@ def incorrect_function(x, **kwargs):
data.groupby("key")["data"].agg(incorrect_function, engine="numba", a=1)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
@pytest.mark.parametrize("jit", [True, False])
Expand Down Expand Up @@ -76,7 +76,7 @@ def func_numba(values, index):
tm.assert_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
@pytest.mark.parametrize("jit", [True, False])
Expand Down Expand Up @@ -121,7 +121,7 @@ def func_2(values, index):
tm.assert_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_use_global_config():
def func_1(values, index):
return np.mean(values) - 3.4
Expand All @@ -136,7 +136,7 @@ def func_1(values, index):
tm.assert_frame_equal(expected, result)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.parametrize(
"agg_func",
[
Expand All @@ -158,7 +158,7 @@ def test_multifunc_notimplimented(agg_func):
grouped[1].agg(agg_func, engine="numba")


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_args_not_cached():
# GH 41647
def sum_last(values, index, n):
Expand All @@ -175,7 +175,7 @@ def sum_last(values, index, n):
tm.assert_series_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_index_data_correctly_passed():
# GH 43133
def f(values, index):
Expand Down
16 changes: 8 additions & 8 deletions pandas/tests/groupby/transform/test_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pandas.core.util.numba_ import NUMBA_FUNC_CACHE


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_correct_function_signature():
def incorrect_function(x):
return x + 1
Expand All @@ -28,7 +28,7 @@ def incorrect_function(x):
data.groupby("key")["data"].transform(incorrect_function, engine="numba")


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_check_nopython_kwargs():
def incorrect_function(x, **kwargs):
return x + 1
Expand All @@ -44,7 +44,7 @@ def incorrect_function(x, **kwargs):
data.groupby("key")["data"].transform(incorrect_function, engine="numba", a=1)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
@pytest.mark.parametrize("jit", [True, False])
Expand Down Expand Up @@ -73,7 +73,7 @@ def func(values, index):
tm.assert_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
@pytest.mark.parametrize("jit", [True, False])
Expand Down Expand Up @@ -118,7 +118,7 @@ def func_2(values, index):
tm.assert_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_use_global_config():
def func_1(values, index):
return values + 1
Expand All @@ -133,7 +133,7 @@ def func_1(values, index):
tm.assert_frame_equal(expected, result)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.parametrize(
"agg_func", [["min", "max"], "min", {"B": ["min", "max"], "C": "sum"}]
)
Expand All @@ -149,7 +149,7 @@ def test_multifunc_notimplimented(agg_func):
grouped[1].transform(agg_func, engine="numba")


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_args_not_cached():
# GH 41647
def sum_last(values, index, n):
Expand All @@ -166,7 +166,7 @@ def sum_last(values, index, n):
tm.assert_series_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_index_data_correctly_passed():
# GH 43133
def f(values, index):
Expand Down
6 changes: 2 additions & 4 deletions pandas/tests/window/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,15 @@ def ignore_na(request):
return request.param


@pytest.fixture(
params=[pytest.param("numba", marks=td.skip_if_no("numba", "0.46.0")), "cython"]
)
@pytest.fixture(params=[pytest.param("numba", marks=td.skip_if_no("numba")), "cython"])
def engine(request):
"""engine keyword argument for rolling.apply"""
return request.param


@pytest.fixture(
params=[
pytest.param(("numba", True), marks=td.skip_if_no("numba", "0.46.0")),
pytest.param(("numba", True), marks=td.skip_if_no("numba")),
("cython", True),
("cython", False),
]
Expand Down
10 changes: 5 additions & 5 deletions pandas/tests/window/test_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from pandas.core.util.numba_ import NUMBA_FUNC_CACHE


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
class TestEngine:
Expand Down Expand Up @@ -150,7 +150,7 @@ def add(values, x):
tm.assert_frame_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
class TestEWMMean:
@pytest.mark.parametrize(
"grouper", [lambda x: x, lambda x: x.groupby("A")], ids=["None", "groupby"]
Expand Down Expand Up @@ -229,7 +229,7 @@ def test_cython_vs_numba_times(self, grouper, nogil, parallel, nopython, ignore_
tm.assert_frame_equal(result, expected)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_use_global_config():
def f(x):
return np.mean(x) + 2
Expand All @@ -241,15 +241,15 @@ def f(x):
tm.assert_series_equal(expected, result)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
def test_invalid_kwargs_nopython():
with pytest.raises(NumbaUtilError, match="numba does not support kwargs with"):
Series(range(1)).rolling(1).apply(
lambda x: x, kwargs={"a": 1}, engine="numba", raw=True
)


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.slow
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
# Filter warnings when parallel=True and the function can't be parallelized by Numba
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/window/test_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pandas._testing as tm


@td.skip_if_no("numba", "0.46.0")
@td.skip_if_no("numba")
@pytest.mark.filterwarnings("ignore:\\nThe keyword argument")
class TestEWM:
def test_invalid_update(self):
Expand Down