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

Method logical_and

Lib/_pydecimal.py:3342–3360  ·  view source on GitHub ↗

Applies an 'and' 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

3340 return opa, opb
3341
3342 def logical_and(self, other, context=None):
3343 """Applies an 'and' operation between self and other's digits.
3344
3345 Both self and other must be logical numbers.
3346 """
3347 if context is None:
3348 context = getcontext()
3349
3350 other = _convert_other(other, raiseit=True)
3351
3352 if not self._islogical() or not other._islogical():
3353 return context._raise_error(InvalidOperation)
3354
3355 # fill to context.prec
3356 (opa, opb) = self._fill_logical(context, self._int, other._int)
3357
3358 # make the operation, and clean starting zeroes
3359 result = "".join([str(int(a)&int(b)) for a,b in zip(opa,opb)])
3360 return _dec_from_triple(0, result.lstrip('0') or '0', 0)
3361
3362 def logical_invert(self, context=None):
3363 """Invert all its digits.

Callers 4

test_none_argsMethod · 0.95
logical_andMethod · 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