@@ -63,16 +63,28 @@ def test_apply(float_frame, engine, request):
63
63
64
64
@pytest .mark .parametrize ("axis" , [0 , 1 ])
65
65
@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 }
67
69
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 ,
69
76
)
70
77
expected = float_frame + 1
71
78
tm .assert_frame_equal (result , expected )
72
79
73
80
# GH:58712
74
81
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 ,
76
88
)
77
89
expected = float_frame + 3
78
90
tm .assert_frame_equal (result , expected )
@@ -81,18 +93,28 @@ def test_apply_args(float_frame, axis, raw, engine):
81
93
# keyword-only arguments are not supported in numba
82
94
with pytest .raises (
83
95
pd .errors .NumbaUtilError ,
84
- match = "numba does not support kwargs with nopython=True " ,
96
+ match = "numba does not support keyword-only arguments " ,
85
97
):
86
98
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 ,
88
105
)
89
106
90
107
with pytest .raises (
91
108
pd .errors .NumbaUtilError ,
92
- match = "numba does not support kwargs with nopython=True " ,
109
+ match = "numba does not support keyword-only arguments " ,
93
110
):
94
111
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 ,
96
118
)
97
119
98
120
0 commit comments