MCPcopy Index your code
hub / github.com/python/cpython / __abs__

Method __abs__

Lib/_pydecimal.py:1089–1109  ·  view source on GitHub ↗

Returns the absolute value of self. If the keyword argument 'round' is false, do not round. The expression self.__abs__(round=False) is equivalent to self.copy_abs().

(self, round=True, context=None)

Source from the content-addressed store, hash-verified

1087 return ans._fix(context)
1088
1089 def __abs__(self, round=True, context=None):
1090 """Returns the absolute value of self.
1091
1092 If the keyword argument 'round' is false, do not round. The
1093 expression self.__abs__(round=False) is equivalent to
1094 self.copy_abs().
1095 """
1096 if not round:
1097 return self.copy_abs()
1098
1099 if self._is_special:
1100 ans = self._check_nans(context=context)
1101 if ans:
1102 return ans
1103
1104 if self._sign:
1105 ans = self.__neg__(context=context)
1106 else:
1107 ans = self.__pos__(context=context)
1108
1109 return ans
1110
1111 def __add__(self, other, context=None):
1112 """Returns self + other.

Callers 1

absMethod · 0.45

Calls 4

copy_absMethod · 0.95
_check_nansMethod · 0.95
__neg__Method · 0.95
__pos__Method · 0.95

Tested by

no test coverage detected