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

Method _check_nans

Lib/_pydecimal.py:699–729  ·  view source on GitHub ↗

Returns whether the number is not actually one. if self, other are sNaN, signal if self, other are NaN return nan return 0 Done before operations.

(self, other=None, context=None)

Source from the content-addressed store, hash-verified

697 return 0
698
699 def _check_nans(self, other=None, context=None):
700 """Returns whether the number is not actually one.
701
702 if self, other are sNaN, signal
703 if self, other are NaN return nan
704 return 0
705
706 Done before operations.
707 """
708
709 self_is_nan = self._isnan()
710 if other is None:
711 other_is_nan = False
712 else:
713 other_is_nan = other._isnan()
714
715 if self_is_nan or other_is_nan:
716 if context is None:
717 context = getcontext()
718
719 if self_is_nan == 2:
720 return context._raise_error(InvalidOperation, 'sNaN',
721 self)
722 if other_is_nan == 2:
723 return context._raise_error(InvalidOperation, 'sNaN',
724 other)
725 if self_is_nan:
726 return self._fix_nan(context)
727
728 return other._fix_nan(context)
729 return 0
730
731 def _compare_check_nans(self, other, context):
732 """Version of _check_nans used for the signaling comparisons

Callers 15

__eq__Method · 0.95
compareMethod · 0.95
__neg__Method · 0.95
__pos__Method · 0.95
__abs__Method · 0.95
__add__Method · 0.95
__sub__Method · 0.95
__mul__Method · 0.95
__truediv__Method · 0.95
__divmod__Method · 0.95
__mod__Method · 0.95
remainder_nearMethod · 0.95

Calls 4

_isnanMethod · 0.95
_fix_nanMethod · 0.95
getcontextFunction · 0.85
_raise_errorMethod · 0.80

Tested by

no test coverage detected