Skip to content

Commit 085ae73

Browse files
committed
add nopython test in test_apply_args
1 parent 8925b3a commit 085ae73

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

pandas/tests/apply/test_frame_apply.py

+29-7
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,28 @@ def test_apply(float_frame, engine, request):
6363

6464
@pytest.mark.parametrize("axis", [0, 1])
6565
@pytest.mark.parametrize("raw", [True, False])
66-
def test_apply_args(float_frame, axis, raw, engine):
66+
@pytest.mark.parametrize("nopython", [True, False])
67+
def test_apply_args(float_frame, axis, raw, engine, nopython):
68+
engine_kwargs = {"nopython": nopython}
6769
result = float_frame.apply(
68-
lambda x, y: x + y, axis, args=(1,), raw=raw, engine=engine
70+
lambda x, y: x + y,
71+
axis,
72+
args=(1,),
73+
raw=raw,
74+
engine=engine,
75+
engine_kwargs=engine_kwargs,
6976
)
7077
expected = float_frame + 1
7178
tm.assert_frame_equal(result, expected)
7279

7380
# GH:58712
7481
result = float_frame.apply(
75-
lambda x, a, b: x + a + b, args=(1,), b=2, engine=engine, raw=raw
82+
lambda x, a, b: x + a + b,
83+
args=(1,),
84+
b=2,
85+
raw=raw,
86+
engine=engine,
87+
engine_kwargs=engine_kwargs,
7688
)
7789
expected = float_frame + 3
7890
tm.assert_frame_equal(result, expected)
@@ -81,18 +93,28 @@ def test_apply_args(float_frame, axis, raw, engine):
8193
# keyword-only arguments are not supported in numba
8294
with pytest.raises(
8395
pd.errors.NumbaUtilError,
84-
match="numba does not support kwargs with nopython=True",
96+
match="numba does not support keyword-only arguments",
8597
):
8698
float_frame.apply(
87-
lambda x, a, *, b: x + a + b, args=(1,), b=2, engine=engine, raw=raw
99+
lambda x, a, *, b: x + a + b,
100+
args=(1,),
101+
b=2,
102+
raw=raw,
103+
engine=engine,
104+
engine_kwargs=engine_kwargs,
88105
)
89106

90107
with pytest.raises(
91108
pd.errors.NumbaUtilError,
92-
match="numba does not support kwargs with nopython=True",
109+
match="numba does not support keyword-only arguments",
93110
):
94111
float_frame.apply(
95-
lambda *x, b: x[0] + x[1] + b, args=(1,), b=2, engine=engine, raw=raw
112+
lambda *x, b: x[0] + x[1] + b,
113+
args=(1,),
114+
b=2,
115+
raw=raw,
116+
engine=engine,
117+
engine_kwargs=engine_kwargs,
96118
)
97119

98120

0 commit comments

Comments
 (0)