34
34
# methods
35
35
36
36
37
- def _create_methods (arith_method , radd_func , comp_method , bool_method ,
37
+ def _create_methods (arith_method , comp_method , bool_method ,
38
38
use_numexpr , special = False , default_axis = 'columns' ):
39
39
# creates actual methods based upon arithmetic, comp and bool method
40
40
# constructors.
@@ -55,14 +55,14 @@ def names(x):
55
55
return "__%s__" % x
56
56
else :
57
57
names = lambda x : x
58
- radd_func = radd_func or operator . add
58
+
59
59
# Inframe, all special methods have default_axis=None, flex methods have
60
60
# default_axis set to the default (columns)
61
61
# yapf: disable
62
62
new_methods = dict (
63
63
add = arith_method (operator .add , names ('add' ), op ('+' ),
64
64
default_axis = default_axis ),
65
- radd = arith_method (radd_func , names ('radd' ), op ('+' ),
65
+ radd = arith_method (lambda x , y : y + x , names ('radd' ), op ('+' ),
66
66
default_axis = default_axis ),
67
67
sub = arith_method (operator .sub , names ('sub' ), op ('-' ),
68
68
default_axis = default_axis ),
@@ -149,7 +149,7 @@ def add_methods(cls, new_methods, force, select, exclude):
149
149
150
150
# ----------------------------------------------------------------------
151
151
# Arithmetic
152
- def add_special_arithmetic_methods (cls , arith_method = None , radd_func = None ,
152
+ def add_special_arithmetic_methods (cls , arith_method = None ,
153
153
comp_method = None , bool_method = None ,
154
154
use_numexpr = True , force = False , select = None ,
155
155
exclude = None ):
@@ -162,8 +162,6 @@ def add_special_arithmetic_methods(cls, arith_method=None, radd_func=None,
162
162
arith_method : function (optional)
163
163
factory for special arithmetic methods, with op string:
164
164
f(op, name, str_rep, default_axis=None, fill_zeros=None, **eval_kwargs)
165
- radd_func : function (optional)
166
- Possible replacement for ``operator.add`` for compatibility
167
165
comp_method : function, optional,
168
166
factory for rich comparison - signature: f(op, name, str_rep)
169
167
use_numexpr : bool, default True
@@ -176,12 +174,11 @@ def add_special_arithmetic_methods(cls, arith_method=None, radd_func=None,
176
174
exclude : iterable of strings (optional)
177
175
if passed, will not set functions with names in exclude
178
176
"""
179
- radd_func = radd_func or operator .add
180
177
181
178
# in frame, special methods have default_axis = None, comp methods use
182
179
# 'columns'
183
180
184
- new_methods = _create_methods (arith_method , radd_func , comp_method ,
181
+ new_methods = _create_methods (arith_method , comp_method ,
185
182
bool_method , use_numexpr , default_axis = None ,
186
183
special = True )
187
184
@@ -218,7 +215,7 @@ def f(self, other):
218
215
exclude = exclude )
219
216
220
217
221
- def add_flex_arithmetic_methods (cls , flex_arith_method , radd_func = None ,
218
+ def add_flex_arithmetic_methods (cls , flex_arith_method ,
222
219
flex_comp_method = None , flex_bool_method = None ,
223
220
use_numexpr = True , force = False , select = None ,
224
221
exclude = None ):
@@ -231,9 +228,6 @@ def add_flex_arithmetic_methods(cls, flex_arith_method, radd_func=None,
231
228
flex_arith_method : function
232
229
factory for special arithmetic methods, with op string:
233
230
f(op, name, str_rep, default_axis=None, fill_zeros=None, **eval_kwargs)
234
- radd_func : function (optional)
235
- Possible replacement for ``lambda x, y: operator.add(y, x)`` for
236
- compatibility
237
231
flex_comp_method : function, optional,
238
232
factory for rich comparison - signature: f(op, name, str_rep)
239
233
use_numexpr : bool, default True
@@ -246,9 +240,8 @@ def add_flex_arithmetic_methods(cls, flex_arith_method, radd_func=None,
246
240
exclude : iterable of strings (optional)
247
241
if passed, will not set functions with names in exclude
248
242
"""
249
- radd_func = radd_func or (lambda x , y : operator .add (y , x ))
250
243
# in frame, default axis is 'columns', doesn't matter for series and panel
251
- new_methods = _create_methods (flex_arith_method , radd_func ,
244
+ new_methods = _create_methods (flex_arith_method ,
252
245
flex_comp_method , flex_bool_method ,
253
246
use_numexpr , default_axis = 'columns' ,
254
247
special = False )
@@ -858,17 +851,6 @@ def wrapper(self, other):
858
851
return wrapper
859
852
860
853
861
- def _radd_compat (left , right ):
862
- radd = lambda x , y : y + x
863
- # GH #353, NumPy 1.5.1 workaround
864
- try :
865
- output = radd (left , right )
866
- except TypeError :
867
- raise
868
-
869
- return output
870
-
871
-
872
854
_op_descriptions = {'add' : {'op' : '+' ,
873
855
'desc' : 'Addition' ,
874
856
'reversed' : False ,
@@ -963,11 +945,9 @@ def flex_wrapper(self, other, level=None, fill_value=None, axis=0):
963
945
964
946
965
947
series_flex_funcs = dict (flex_arith_method = _flex_method_SERIES ,
966
- radd_func = _radd_compat ,
967
948
flex_comp_method = _comp_method_SERIES )
968
949
969
950
series_special_funcs = dict (arith_method = _arith_method_SERIES ,
970
- radd_func = _radd_compat ,
971
951
comp_method = _comp_method_SERIES ,
972
952
bool_method = _bool_method_SERIES )
973
953
@@ -1209,11 +1189,9 @@ def f(self, other):
1209
1189
1210
1190
1211
1191
frame_flex_funcs = dict (flex_arith_method = _arith_method_FRAME ,
1212
- radd_func = _radd_compat ,
1213
1192
flex_comp_method = _flex_comp_method_FRAME )
1214
1193
1215
1194
frame_special_funcs = dict (arith_method = _arith_method_FRAME ,
1216
- radd_func = _radd_compat ,
1217
1195
comp_method = _comp_method_FRAME ,
1218
1196
bool_method = _arith_method_FRAME )
1219
1197
0 commit comments