コード例 #1
0
 def test_idiv__on_int(self):
     """ Verify that (old) /= works on proxy[int]. """
     a = b = proxy(7)
     b = operator.idiv(b, 2)
     self.assertEqual(a, 7)
     self.assertEqual(b, 3)
     self.assertTrue(issubclass(type(a), proxy))
     self.assertTrue(issubclass(type(b), proxy))
コード例 #2
0
 def test_inplace(self):
     class C(object):
         def __iadd__     (self, other): return "iadd"
         def __iand__     (self, other): return "iand"
         def __idiv__     (self, other): return "idiv"
         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 __imatmul__  (self, other): return "imatmul"
         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.idiv     (c, 5), "idiv")
     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.imatmul  (c, 5), "imatmul")
     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")
     self.assertEqual(operator.irepeat  (c, 5), "imul")
     self.assertEqual(operator.__iadd__     (c, 5), "iadd")
     self.assertEqual(operator.__iand__     (c, 5), "iand")
     self.assertEqual(operator.__idiv__     (c, 5), "idiv")
     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.__imatmul__  (c, 5), "imatmul")
     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")
     self.assertEqual(operator.__irepeat__  (c, 5), "imul")
コード例 #3
0
ファイル: test_operator.py プロジェクト: Afey/pyjs
 def test_inplace(self):
     class C(object):
         def __iadd__     (self, other): return "iadd"
         def __iand__     (self, other): return "iand"
         def __idiv__     (self, other): return "idiv"
         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.idiv     (c, 5), "idiv")
     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")
     self.assertEqual(operator.irepeat  (c, 5), "imul")
     self.assertEqual(operator.__iadd__     (c, 5), "iadd")
     self.assertEqual(operator.__iand__     (c, 5), "iand")
     self.assertEqual(operator.__idiv__     (c, 5), "idiv")
     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")
     self.assertEqual(operator.__irepeat__  (c, 5), "imul")
コード例 #4
0
 def __idiv__(self, other):
     self.__wrapped__ = operator.idiv(self.__wrapped__, other)
     return self
コード例 #5
0
ファイル: test_operators.py プロジェクト: GaZ3ll3/numba
 def idiv_usecase(x, y):
     return operator.idiv(x, y)
コード例 #6
0
ファイル: wrappers.py プロジェクト: Arable/evepod
 def __idiv__(self, other):
     self.__wrapped__ = operator.idiv(self.__wrapped__, other)
     return self
コード例 #7
0
ファイル: test_operators.py プロジェクト: menghaozhu/hat
 def idiv_usecase(x, y):
     return operator.idiv(x, y)
コード例 #8
0
ファイル: operator_demo.py プロジェクト: sjl421/Python_Lib
a = 8
b = operator.ior(a, 1)
print a
print b

#将与自身的值相异或的值赋给自身 同 ^=
#但是不改变自身的值,返回值返回相异或的结果
a = 8
b = operator.ixor(a, 1)
print a
print b

#将与自身相除取整的值赋给自身 同 /=
#但是不改变自身的值,返回值返回相除的结果
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
コード例 #9
0
ファイル: vec2-test.py プロジェクト: mjs/brokenspell
 def test_idiv(self):
     a = Vec2(31, 41)
     operator.idiv(a, 10)
     self.assertEquals(a, Vec2(3, 4))
コード例 #10
0
ファイル: operator_demo.py プロジェクト: windard/Python_Lib
a = 8
b = operator.ior(a,1)
print a
print b

#将与自身的值相异或的值赋给自身 同 ^=
#但是不改变自身的值,返回值返回相异或的结果
a = 8
b = operator.ixor(a,1)
print a
print b

#将与自身相除取整的值赋给自身 同 /=
#但是不改变自身的值,返回值返回相除的结果
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