Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/pandas/core/roperator.py: 45%

29 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1""" 

2Reversed Operations not available in the stdlib operator module. 

3Defining these instead of using lambdas allows us to reference them by name. 

4""" 

5from __future__ import annotations 

6 

7import operator 

8 

9 

10def radd(left, right): 

11 return right + left 

12 

13 

14def rsub(left, right): 

15 return right - left 

16 

17 

18def rmul(left, right): 

19 return right * left 

20 

21 

22def rdiv(left, right): 

23 return right / left 

24 

25 

26def rtruediv(left, right): 

27 return right / left 

28 

29 

30def rfloordiv(left, right): 

31 return right // left 

32 

33 

34def rmod(left, right): 

35 # check if right is a string as % is the string 

36 # formatting operation; this is a TypeError 

37 # otherwise perform the op 

38 if isinstance(right, str): 

39 typ = type(left).__name__ 

40 raise TypeError(f"{typ} cannot perform the operation mod") 

41 

42 return right % left 

43 

44 

45def rdivmod(left, right): 

46 return divmod(right, left) 

47 

48 

49def rpow(left, right): 

50 return right**left 

51 

52 

53def rand_(left, right): 

54 return operator.and_(right, left) 

55 

56 

57def ror_(left, right): 

58 return operator.or_(right, left) 

59 

60 

61def rxor(left, right): 

62 return operator.xor(right, left)