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

Method logical_xor

Lib/_pydecimal.py:3392–3410  ·  view source on GitHub ↗

Applies an 'xor' operation between self and other's digits. Both self and other must be logical numbers.

(self, other, context=None)

Source from the content-addressed store, hash-verified

3390 return _dec_from_triple(0, result.lstrip('0') or '0', 0)
3391
3392 def logical_xor(self, other, context=None):
3393 """Applies an 'xor' operation between self and other's digits.
3394
3395 Both self and other must be logical numbers.
3396 """
3397 if context is None:
3398 context = getcontext()
3399
3400 other = _convert_other(other, raiseit=True)
3401
3402 if not self._islogical() or not other._islogical():
3403 return context._raise_error(InvalidOperation)
3404
3405 # fill to context.prec
3406 (opa, opb) = self._fill_logical(context, self._int, other._int)
3407
3408 # make the operation, and clean starting zeroes
3409 result = "".join([str(int(a)^int(b)) for a,b in zip(opa,opb)])
3410 return _dec_from_triple(0, result.lstrip('0') or '0', 0)
3411
3412 def max_mag(self, other, context=None):
3413 """Compares the values numerically with their sign ignored."""

Callers 5

logical_invertMethod · 0.95
test_none_argsMethod · 0.95
logical_xorMethod · 0.45
test_named_parametersMethod · 0.45

Calls 9

_islogicalMethod · 0.95
_fill_logicalMethod · 0.95
getcontextFunction · 0.85
_convert_otherFunction · 0.85
strFunction · 0.85
_dec_from_tripleFunction · 0.85
_raise_errorMethod · 0.80
joinMethod · 0.45
lstripMethod · 0.45

Tested by 3

test_none_argsMethod · 0.76
test_named_parametersMethod · 0.36