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

Method _compare_check_nans

Lib/_pydecimal.py:728–759  ·  view source on GitHub ↗

Version of _check_nans used for the signaling comparisons compare_signal, __le__, __lt__, __ge__, __gt__. Signal InvalidOperation if either self or other is a (quiet or signaling) NaN. Signaling NaNs take precedence over quiet NaNs. Return 0 if neither oper

(self, other, context)

Source from the content-addressed store, hash-verified

726 return 0
727
728 def _compare_check_nans(self, other, context):
729 """Version of _check_nans used for the signaling comparisons
730 compare_signal, __le__, __lt__, __ge__, __gt__.
731
732 Signal InvalidOperation if either self or other is a (quiet
733 or signaling) NaN. Signaling NaNs take precedence over quiet
734 NaNs.
735
736 Return 0 if neither operand is a NaN.
737
738 """
739 if context is None:
740 context = getcontext()
741
742 if self._is_special or other._is_special:
743 if self.is_snan():
744 return context._raise_error(InvalidOperation,
745 'comparison involving sNaN',
746 self)
747 elif other.is_snan():
748 return context._raise_error(InvalidOperation,
749 'comparison involving sNaN',
750 other)
751 elif self.is_qnan():
752 return context._raise_error(InvalidOperation,
753 'comparison involving NaN',
754 self)
755 elif other.is_qnan():
756 return context._raise_error(InvalidOperation,
757 'comparison involving NaN',
758 other)
759 return 0
760
761 def __bool__(self):
762 """Return True if self is nonzero; otherwise return False.

Callers 5

__lt__Method · 0.95
__le__Method · 0.95
__gt__Method · 0.95
__ge__Method · 0.95
compare_signalMethod · 0.95

Calls 4

is_snanMethod · 0.95
is_qnanMethod · 0.95
getcontextFunction · 0.85
_raise_errorMethod · 0.80

Tested by

no test coverage detected