MCPcopy Index your code
hub / github.com/RustPython/RustPython / __abs__

Method __abs__

Lib/_pydecimal.py:1086–1106  ·  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

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