Coverage for /home/martinb/.local/share/virtualenvs/camcops/lib/python3.6/site-packages/pandas/core/ops/roperator.py : 46%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""
2Reversed Operations not available in the stdlib operator module.
3Defining these instead of using lambdas allows us to reference them by name.
4"""
5import operator
8def radd(left, right):
9 return right + left
12def rsub(left, right):
13 return right - left
16def rmul(left, right):
17 return right * left
20def rdiv(left, right):
21 return right / left
24def rtruediv(left, right):
25 return right / left
28def rfloordiv(left, right):
29 return right // left
32def 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 typ = type(left).__name__
38 raise TypeError(f"{typ} cannot perform the operation mod")
40 return right % left
43def rdivmod(left, right):
44 return divmod(right, left)
47def rpow(left, right):
48 return right ** left
51def rand_(left, right):
52 return operator.and_(right, left)
55def ror_(left, right):
56 return operator.or_(right, left)
59def rxor(left, right):
60 return operator.xor(right, left)