File tree 2 files changed +76
-61
lines changed
2 files changed +76
-61
lines changed Original file line number Diff line number Diff line change 51
51
import pandas .core .common as com
52
52
import pandas .core .missing as missing
53
53
54
+ from .roperator import ( # noqa:F401
55
+ radd ,
56
+ rand_ ,
57
+ rdiv ,
58
+ rdivmod ,
59
+ rfloordiv ,
60
+ rmod ,
61
+ rmul ,
62
+ ror_ ,
63
+ rpow ,
64
+ rsub ,
65
+ rtruediv ,
66
+ rxor ,
67
+ )
68
+
54
69
# -----------------------------------------------------------------------------
55
70
# Ops Wrapping Utilities
56
71
@@ -151,67 +166,6 @@ def maybe_upcast_for_op(obj):
151
166
return obj
152
167
153
168
154
- # -----------------------------------------------------------------------------
155
- # Reversed Operations not available in the stdlib operator module.
156
- # Defining these instead of using lambdas allows us to reference them by name.
157
-
158
-
159
- def radd (left , right ):
160
- return right + left
161
-
162
-
163
- def rsub (left , right ):
164
- return right - left
165
-
166
-
167
- def rmul (left , right ):
168
- return right * left
169
-
170
-
171
- def rdiv (left , right ):
172
- return right / left
173
-
174
-
175
- def rtruediv (left , right ):
176
- return right / left
177
-
178
-
179
- def rfloordiv (left , right ):
180
- return right // left
181
-
182
-
183
- def rmod (left , right ):
184
- # check if right is a string as % is the string
185
- # formatting operation; this is a TypeError
186
- # otherwise perform the op
187
- if isinstance (right , str ):
188
- raise TypeError (
189
- "{typ} cannot perform the operation mod" .format (typ = type (left ).__name__ )
190
- )
191
-
192
- return right % left
193
-
194
-
195
- def rdivmod (left , right ):
196
- return divmod (right , left )
197
-
198
-
199
- def rpow (left , right ):
200
- return right ** left
201
-
202
-
203
- def rand_ (left , right ):
204
- return operator .and_ (right , left )
205
-
206
-
207
- def ror_ (left , right ):
208
- return operator .or_ (right , left )
209
-
210
-
211
- def rxor (left , right ):
212
- return operator .xor (right , left )
213
-
214
-
215
169
# -----------------------------------------------------------------------------
216
170
217
171
Original file line number Diff line number Diff line change
1
+ """
2
+ Reversed Operations not available in the stdlib operator module.
3
+ Defining these instead of using lambdas allows us to reference them by name.
4
+ """
5
+ import operator
6
+
7
+
8
+ def radd (left , right ):
9
+ return right + left
10
+
11
+
12
+ def rsub (left , right ):
13
+ return right - left
14
+
15
+
16
+ def rmul (left , right ):
17
+ return right * left
18
+
19
+
20
+ def rdiv (left , right ):
21
+ return right / left
22
+
23
+
24
+ def rtruediv (left , right ):
25
+ return right / left
26
+
27
+
28
+ def rfloordiv (left , right ):
29
+ return right // left
30
+
31
+
32
+ def rmod (left , right ):
33
+ # check if right is a string as % is the string
34
+ # formatting operation; this is a TypeError
35
+ # otherwise perform the op
36
+ if isinstance (right , str ):
37
+ raise TypeError (
38
+ "{typ} cannot perform the operation mod" .format (typ = type (left ).__name__ )
39
+ )
40
+
41
+ return right % left
42
+
43
+
44
+ def rdivmod (left , right ):
45
+ return divmod (right , left )
46
+
47
+
48
+ def rpow (left , right ):
49
+ return right ** left
50
+
51
+
52
+ def rand_ (left , right ):
53
+ return operator .and_ (right , left )
54
+
55
+
56
+ def ror_ (left , right ):
57
+ return operator .or_ (right , left )
58
+
59
+
60
+ def rxor (left , right ):
61
+ return operator .xor (right , left )
You can’t perform that action at this time.
0 commit comments