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

Method abs

Lib/_pydecimal.py:4107–4126  ·  view source on GitHub ↗

Returns the absolute value of the operand. If the operand is negative, the result is the same as using the minus operation on the operand. Otherwise, the result is the same as using the plus operation on the operand. >>> ExtendedContext.abs(Decimal('2.1'))

(self, a)

Source from the content-addressed store, hash-verified

4105
4106 # Methods
4107 def abs(self, a):
4108 """Returns the absolute value of the operand.
4109
4110 If the operand is negative, the result is the same as using the minus
4111 operation on the operand. Otherwise, the result is the same as using
4112 the plus operation on the operand.
4113
4114 >>> ExtendedContext.abs(Decimal('2.1'))
4115 Decimal('2.1')
4116 >>> ExtendedContext.abs(Decimal('-100'))
4117 Decimal('100')
4118 >>> ExtendedContext.abs(Decimal('101.5'))
4119 Decimal('101.5')
4120 >>> ExtendedContext.abs(Decimal('-101.5'))
4121 Decimal('101.5')
4122 >>> ExtendedContext.abs(-1)
4123 Decimal('1')
4124 """
4125 a = _convert_other(a, raiseit=True)
4126 return a.__abs__(context=self)
4127
4128 def add(self, a, b):
4129 """Return the sum of the two operands.

Callers 15

test_absMethod · 0.95
test_absMethod · 0.80
seedMethod · 0.80
normal_dist_inv_cdfFunction · 0.80
format_int_localeMethod · 0.80
format_float_localeMethod · 0.80
format_floatMethod · 0.80
format_intMethod · 0.80
format_complex_floatMethod · 0.80
mod_Function · 0.80
ulpFunction · 0.80
round_float_digitsFunction · 0.80

Calls 2

_convert_otherFunction · 0.85
__abs__Method · 0.45

Tested by 2

test_absMethod · 0.76
test_absMethod · 0.64