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

Method __mod__

Lib/_pydecimal.py:1417–1442  ·  view source on GitHub ↗

self % other

(self, other, context=None)

Source from the content-addressed store, hash-verified

1415 return other.__divmod__(self, context=context)
1416
1417 def __mod__(self, other, context=None):
1418 """
1419 self % other
1420 """
1421 other = _convert_other(other)
1422 if other is NotImplemented:
1423 return other
1424
1425 if context is None:
1426 context = getcontext()
1427
1428 ans = self._check_nans(other, context)
1429 if ans:
1430 return ans
1431
1432 if self._isinfinity():
1433 return context._raise_error(InvalidOperation, 'INF % x')
1434 elif not other:
1435 if self:
1436 return context._raise_error(InvalidOperation, 'x % 0')
1437 else:
1438 return context._raise_error(DivisionUndefined, '0 % 0')
1439
1440 remainder = self._divide(other, context)[1]
1441 remainder = remainder._fix(context)
1442 return remainder
1443
1444 def __rmod__(self, other, context=None):
1445 """Swaps self/other and returns __mod__."""

Callers 2

__rmod__Method · 0.45
remainderMethod · 0.45

Calls 7

_check_nansMethod · 0.95
_isinfinityMethod · 0.95
_divideMethod · 0.95
_convert_otherFunction · 0.85
getcontextFunction · 0.85
_raise_errorMethod · 0.80
_fixMethod · 0.80

Tested by

no test coverage detected