本文整理汇总了Python中operator.ifloordiv方法的典型用法代码示例。如果您正苦于以下问题:Python operator.ifloordiv方法的具体用法?Python operator.ifloordiv怎么用?Python operator.ifloordiv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类operator
的用法示例。
在下文中一共展示了operator.ifloordiv方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inplace_success
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def test_inplace_success(self):
# Inplace ops should work even if a specialized version is not
# implemented, falling back to x = x <op> y
a = self.spmatrix(np.eye(5))
b = self.spmatrix(np.eye(5))
bp = self.spmatrix(np.eye(5))
b += a
bp = bp + a
assert_allclose(b.A, bp.A)
b *= a
bp = bp * a
assert_allclose(b.A, bp.A)
b -= a
bp = bp - a
assert_allclose(b.A, bp.A)
assert_raises(TypeError, operator.ifloordiv, a, b)
示例2: testIFloorDiv
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def testIFloorDiv(self):
self.augmentedAssignCheck(operator.ifloordiv, jmin=1)
示例3: test_inplace_dense
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def test_inplace_dense(self):
a = np.ones((3, 4))
b = self.spmatrix(a)
x = a.copy()
y = a.copy()
x += a
y += b
assert_array_equal(x, y)
x = a.copy()
y = a.copy()
x -= a
y -= b
assert_array_equal(x, y)
# This is matrix product, from __rmul__
assert_raises(ValueError, operator.imul, x, b)
x = a.copy()
y = a.copy()
x = x.dot(a.T)
y *= b.T
assert_array_equal(x, y)
# Matrix (non-elementwise) floor division is not defined
assert_raises(TypeError, operator.ifloordiv, x, b)
示例4: test_ifloordiv_scalar
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def test_ifloordiv_scalar(self):
with testing.NumpyError(divide='ignore'):
self.check_array_scalar_op(operator.ifloordiv, no_complex=True)
示例5: test_ifloordiv_array
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def test_ifloordiv_array(self):
if '1.16.1' <= numpy.lib.NumpyVersion(numpy.__version__) < '1.18.0':
self.skipTest("NumPy Issue #12927")
with testing.NumpyError(divide='ignore'):
self.check_array_array_op(operator.ifloordiv, no_complex=True)
示例6: test_broadcasted_ifloordiv
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def test_broadcasted_ifloordiv(self):
if '1.16.1' <= numpy.lib.NumpyVersion(numpy.__version__) < '1.18.0':
self.skipTest("NumPy Issue #12927")
with testing.NumpyError(divide='ignore'):
self.check_array_broadcasted_op(operator.ifloordiv,
no_complex=True)
示例7: _test_quantity_ifloordiv
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def _test_quantity_ifloordiv(self, unit, func):
func(op.ifloordiv, 10.0, '4.2*meter', '2/meter', unit)
func(op.ifloordiv, '24*meter', 10.0, '2*meter', unit)
func(op.ifloordiv, '10*meter', '4.2*inch', '2*meter/inch', unit)
示例8: test_issue52
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def test_issue52(self):
u1 = UnitRegistry()
u2 = UnitRegistry()
q1 = u1.meter
q2 = u2.meter
import operator as op
for fun in (op.add, op.iadd,
op.sub, op.isub,
op.mul, op.imul,
op.floordiv, op.ifloordiv,
op.truediv, op.itruediv):
self.assertRaises(ValueError, fun, q1, q2)
示例9: __ifloordiv__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def __ifloordiv__(self, other):
if not isinstance(self._magnitude, ndarray):
return self._mul_div(other, operator.floordiv, units_op=operator.itruediv)
else:
return self._imul_div(other, operator.ifloordiv, units_op=operator.itruediv)
示例10: _test_errors
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def _test_errors(self, poly):
self.assertRaises(ValueError, poly.from_terms, 'x**2')
self.assertRaises(TypeError, poly, 0.1)
self.assertRaises(TypeError, poly, gfpx.GFpX(257)(0))
self.assertRaises(ValueError, poly, [poly.p])
self.assertRaises(TypeError, operator.add, poly(0), 0.1)
self.assertRaises(TypeError, operator.iadd, poly(0), 0.1)
self.assertRaises(TypeError, operator.sub, poly(0), 0.1)
self.assertRaises(TypeError, operator.sub, 0.1, poly(0))
self.assertRaises(TypeError, operator.isub, poly(0), 0.1)
self.assertRaises(TypeError, operator.mul, poly(0), 0.1)
self.assertRaises(TypeError, operator.imul, poly(0), 0.1)
self.assertRaises(TypeError, operator.lshift, poly(0), 0.1)
self.assertRaises(TypeError, operator.lshift, 0.1, poly(0))
self.assertRaises(TypeError, operator.ilshift, poly(0), 0.1)
self.assertRaises(TypeError, operator.rshift, poly(0), 0.1)
self.assertRaises(TypeError, operator.rshift, 0.1, poly(0))
self.assertRaises(TypeError, operator.irshift, poly(0), 0.1)
self.assertRaises(TypeError, operator.floordiv, poly(0), 0.1)
self.assertRaises(TypeError, operator.floordiv, 0.1, poly(0))
self.assertRaises(TypeError, operator.ifloordiv, poly(0), 0.1)
self.assertRaises(TypeError, operator.mod, poly(0), 0.1)
self.assertRaises(TypeError, operator.mod, 0.1, poly(0))
self.assertRaises(TypeError, operator.imod, poly(0), 0.1)
self.assertRaises(TypeError, divmod, poly(0), 0.1)
self.assertRaises(TypeError, divmod, 0.1, poly(0))
self.assertRaises(TypeError, operator.lt, poly(0), 0.1)
self.assertRaises(TypeError, operator.lt, 0.1, poly(0)) # NB: tests >
self.assertRaises(TypeError, operator.le, poly(0), 0.1)
self.assertRaises(TypeError, operator.le, 0.1, poly(0)) # NB: tests <
self.assertRaises(ZeroDivisionError, poly.invert, poly(283), poly(0))
self.assertRaises(ZeroDivisionError, poly.invert, poly(283), poly(283))
self.assertRaises(ZeroDivisionError, poly.mod, poly(283), poly(0))
self.assertRaises(ZeroDivisionError, poly.divmod, poly(283), poly(0))
self.assertRaises(ValueError, operator.pow, poly(3), -16)
示例11: __ifloordiv__
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
def __ifloordiv__(self, other):
return Expression((self, other), operator.ifloordiv)
示例12: test_inplace
# 需要导入模块: import operator [as 别名]
# 或者: from operator import ifloordiv [as 别名]
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")