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

Method max

Lib/_pydecimal.py:4816–4841  ·  view source on GitHub ↗

max compares two values numerically and returns the maximum. If either operand is a NaN then the general rules apply. Otherwise, the operands are compared as though by the compare operation. If they are numerically equal then the left-hand operand is chosen as the r

(self, a, b)

Source from the content-addressed store, hash-verified

4814 return a.logical_xor(b, context=self)
4815
4816 def max(self, a, b):
4817 """max compares two values numerically and returns the maximum.
4818
4819 If either operand is a NaN then the general rules apply.
4820 Otherwise, the operands are compared as though by the compare
4821 operation. If they are numerically equal then the left-hand operand
4822 is chosen as the result. Otherwise the maximum (closer to positive
4823 infinity) of the two operands is chosen as the result.
4824
4825 >>> ExtendedContext.max(Decimal('3'), Decimal('2'))
4826 Decimal('3')
4827 >>> ExtendedContext.max(Decimal('-10'), Decimal('3'))
4828 Decimal('3')
4829 >>> ExtendedContext.max(Decimal('1.0'), Decimal('1'))
4830 Decimal('1')
4831 >>> ExtendedContext.max(Decimal('7'), Decimal('NaN'))
4832 Decimal('7')
4833 >>> ExtendedContext.max(1, 2)
4834 Decimal('2')
4835 >>> ExtendedContext.max(Decimal(1), 2)
4836 Decimal('2')
4837 >>> ExtendedContext.max(1, Decimal(2))
4838 Decimal('2')
4839 """
4840 a = _convert_other(a, raiseit=True)
4841 return a.max(b, context=self)
4842
4843 def max_mag(self, a, b):
4844 """Compares the values numerically with their sign ignored.

Callers 1

test_maxMethod · 0.95

Calls 2

_convert_otherFunction · 0.85
maxMethod · 0.45

Tested by 1

test_maxMethod · 0.76