def operator_ilshift(size): a = Array(size, 'int32') b = Array(size, 'int32') for i in range(size): a[i] = nb_types.int32(i) b[i] = nb_types.int32(size-i-1) operator.ilshift(a, b) return a
def test_inplace(self): #operator = self.module class C(object): def __iadd__ (self, other): return "iadd" def __iand__ (self, other): return "iand" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__ (self, other): return "ilshift" def __imod__ (self, other): return "imod" def __imul__ (self, other): return "imul" def __ior__ (self, other): return "ior" def __ipow__ (self, other): return "ipow" def __irshift__ (self, other): return "irshift" def __isub__ (self, other): return "isub" def __itruediv__ (self, other): return "itruediv" def __ixor__ (self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd (c, 5), "iadd") self.assertEqual(operator.iand (c, 5), "iand") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift (c, 5), "ilshift") self.assertEqual(operator.imod (c, 5), "imod") self.assertEqual(operator.imul (c, 5), "imul") self.assertEqual(operator.ior (c, 5), "ior") self.assertEqual(operator.ipow (c, 5), "ipow") self.assertEqual(operator.irshift (c, 5), "irshift") self.assertEqual(operator.isub (c, 5), "isub") self.assertEqual(operator.itruediv (c, 5), "itruediv") self.assertEqual(operator.ixor (c, 5), "ixor") self.assertEqual(operator.iconcat (c, c), "iadd")
def test_ilshift_trace(self): trace = self.sdk.current_trace span = trace.span() result = operator.ilshift(span, trace) self.assertNotIn(span, trace.spans) self.assertNotIn(span.span_id, trace.span_ids) self.assertIsInstance(result, Span)
def test_inplace(self): #operator = self.module class C(object): def __iadd__(self, other): return "iadd" def __iand__(self, other): return "iand" def __ifloordiv__(self, other): return "ifloordiv" def __ilshift__(self, other): return "ilshift" def __imod__(self, other): return "imod" def __imul__(self, other): return "imul" def __ior__(self, other): return "ior" def __ipow__(self, other): return "ipow" def __irshift__(self, other): return "irshift" def __isub__(self, other): return "isub" def __itruediv__(self, other): return "itruediv" def __ixor__(self, other): return "ixor" def __getitem__(self, other): return 5 # so that C is a sequence c = C() self.assertEqual(operator.iadd(c, 5), "iadd") self.assertEqual(operator.iand(c, 5), "iand") self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv") self.assertEqual(operator.ilshift(c, 5), "ilshift") self.assertEqual(operator.imod(c, 5), "imod") self.assertEqual(operator.imul(c, 5), "imul") self.assertEqual(operator.ior(c, 5), "ior") self.assertEqual(operator.ipow(c, 5), "ipow") self.assertEqual(operator.irshift(c, 5), "irshift") self.assertEqual(operator.isub(c, 5), "isub") self.assertEqual(operator.itruediv(c, 5), "itruediv") self.assertEqual(operator.ixor(c, 5), "ixor") self.assertEqual(operator.iconcat(c, c), "iadd")
def test_ilshift_span(self): span_id = Span.new_span_id() span_a = Span.new(self.trace, span_id) new_span_id = Span.new_span_id() span_b = Span.new(self.trace, new_span_id) result = operator.ilshift(span_b, span_a) self.assertIs(span_a.parent_span, span_b) self.assertIsInstance(result, Span)
def test_class_binary_inplace_operators(self): class WithLotsOfOperators(Class): def __iadd__(self, other): return (self, "iadd", other) def __isub__(self, other): return (self, "isub", other) def __imul__(self, other): return (self, "imul", other) def __imod__(self, other): return (self, "imod", other) def __itruediv__(self, other): return (self, "itruediv", other) def __ifloordiv__(self, other): return (self, "ifloordiv", other) def __ilshift__(self, other): return (self, "ilshift", other) def __irshift__(self, other): return (self, "irshift", other) def __ior__(self, other): return (self, "ior", other) def __iand__(self, other): return (self, "iand", other) def __ixor__(self, other): return (self, "ixor", other) def __imatmul__(self, other): return (self, "imatmul", other) c = WithLotsOfOperators() self.assertEqual(operator.iadd(c, 0), (c, "iadd", 0)) self.assertEqual(operator.isub(c, 0), (c, "isub", 0)) self.assertEqual(operator.imul(c, 0), (c, "imul", 0)) self.assertEqual(operator.imod(c, 0), (c, "imod", 0)) self.assertEqual(operator.itruediv(c, 0), (c, "itruediv", 0)) self.assertEqual(operator.ifloordiv(c, 0), (c, "ifloordiv", 0)) self.assertEqual(operator.ilshift(c, 0), (c, "ilshift", 0)) self.assertEqual(operator.irshift(c, 0), (c, "irshift", 0)) self.assertEqual(operator.ior(c, 0), (c, "ior", 0)) self.assertEqual(operator.iand(c, 0), (c, "iand", 0)) self.assertEqual(operator.ixor(c, 0), (c, "ixor", 0)) self.assertEqual(operator.imatmul(c, 0), (c, "imatmul", 0))
import operator x=operator.ilshift(20,2) print(x)
def bitshift_ileft_usecase(x, y): return operator.ilshift(x, y)
a = 3 b = 2 print(operator.ipow(a, b)) """9.iand() :- This function is used to assign and bitwise and the current value. This operation does “a &= b” operation. Assigning is not performed in case of immutable containers, such as strings, numbers and tuples""" a = 1 b = 1 print(operator.iand(a, b)) """10.ior()- This function is used to assign and bitwise or the current value. This operation does “a |=b ” operation. Assigning is not performed in case of immutable containers, such as strings, numbers and tuples.""" a = 5 b = 1 print(operator.ior(a, b)) """11.ilshift()-This function is used to assign and bitwise leftshift the current value by second argument. This operation does “a <<=b ” operation. Assigning is not performed in case of immutable containers, such as strings, numbers and tuples.""" a = 3 b = 2 print(operator.ilshift(a, b)) """12.irshift()- This function is used to assign and bitwise rightshift the current value by second argument. This operation does “a >>=b ” operation. Assigning is not performed in case of immutable containers, such as strings, numbers and tuples.""" a = 4 b = 1 print(operator.irshift(a, b))
def __ilshift__(self, other): return operator.ilshift(self._wrapped(), other)
print("the string after concatenation is : ", end="") print(y) x = operator.isub(2, 3) print("the value after subtracting and assiging : ", end="") print(x) x = operator.imul(2, 3) print("the value after multiplying and assiging : ", end="") print(x) x = operator.itruediv(2, 3) print("the value after dividing and assign : ", end="") print(x) x = operator.ixor(10, 5) print("the value after xoring and assigning : ", end="") print(x) x = operator.ipow(5, 4) print("the value after exponentiating and assigning : ", end="") print(x) x = operator.ilshift(8, 2) print("the value after bitwise left shift and assigning : ", end="") print(x) x = operator.irshift(8, 2) print("the value after bitwise right shift and assigning : ", end="") print(x)
#将与自身相除取整的值赋给自身 同 /= #但是不改变自身的值,返回值返回相除的结果 a = 9 b = operator.idiv(a, 4) print a print b #将与自身相除取整的值赋给自身 同 //= #但是不改变自身的值,返回值返回相除的结果 a = 9.04 b = operator.ifloordiv(a, 4) print a print b #将与自身相移位的值赋给自身 同 <<= #但是不改变自身的值,返回值返回移位的结果 a = 3 b = operator.ilshift(3, 2) print a print b #将与自身相移位的值赋给自身 同 >>= #但是不改变自身的值,返回值返回移位的结果 a = 3 b = operator.irshift(3, 2) print a print b #同 +a #并不知道有什么用 operator.pos(3)
def update_event(self, inp=-1): self.set_output_val(0, operator.ilshift(self.input(0), self.input(1)))
print(li) operator.delitem(li, slice(1, 4)) print(li) print(operator.getitem(li, slice(0, 2))) s1 = "testing " s2 = "operator" print(operator.concat(s1, s2)) if (operator.contains(s1, s2)): print("Contains") else: print("It doesn't") a = 1 b = 0 print(operator.and_(a, b)) print(operator.or_(a, b)) print(operator.invert(a)) x = 10 y = 5 print(operator.iadd(x, y)) print(operator.isub(x, y)) print(operator.iconcat(s1, s2)) print(operator.imul(x, y)) print(operator.itruediv(x, y)) print(operator.imod(x, y)) print(operator.ixor(x, y)) print(operator.ipow(x, y)) print(operator.iand(x, y)) print(operator.ior(x, y)) print(operator.ilshift(x, y)) print(operator.irshift(x, y))
x = 10 y = 5 x = operator.ior(x, y) print("The value after bitwise or, and assigning : ", end="") print(x) x = 5 y = 4 x = operator.iand(x, y) print("The value after bitwise and, and assigning : ", end="") print(x) #%% ''' ilshift() :- This function is used to assign and bitwise leftshift the current value by second argument.''' import operator # using ilshift() to bitwise left shift and assign value x = 8 y = 2 x = operator.ilshift(x, y) print("The value after bitwise left shift and assigning : ", end="") print(x) x = 8 y = 2 x = operator.irshift(x, y) print("The value after bitwise right shift and assigning : ", end="") print(x)
#将与自身相除取整的值赋给自身 同 /= #但是不改变自身的值,返回值返回相除的结果 a = 9 b = operator.idiv(a,4) print a print b #将与自身相除取整的值赋给自身 同 //= #但是不改变自身的值,返回值返回相除的结果 a = 9.04 b = operator.ifloordiv(a,4) print a print b #将与自身相移位的值赋给自身 同 <<= #但是不改变自身的值,返回值返回移位的结果 a = 3 b = operator.ilshift(3,2) print a print b #将与自身相移位的值赋给自身 同 >>= #但是不改变自身的值,返回值返回移位的结果 a = 3 b = operator.irshift(3,2) print a print b #同 +a #并不知道有什么用 operator.pos(3)