本文整理匯總了Python中operator.ipow方法的典型用法代碼示例。如果您正苦於以下問題:Python operator.ipow方法的具體用法?Python operator.ipow怎麽用?Python operator.ipow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類operator
的用法示例。
在下文中一共展示了operator.ipow方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testIPow
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def testIPow(self):
self.augmentedAssignCheck(operator.ipow, jmax=64)
示例2: check_ipow_scalar
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def check_ipow_scalar(self, xp, x_type, y_type):
a = xp.array([[1, 2, 3], [4, 5, 6]], x_type)
return operator.ipow(a, y_type(3))
示例3: check_ipow_array
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def check_ipow_array(self, xp, x_type, y_type):
a = xp.array([[1, 2, 3], [4, 5, 6]], x_type)
b = xp.array([[6, 5, 4], [3, 2, 1]], y_type)
return operator.ipow(a, b)
示例4: check_broadcasted_ipow
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def check_broadcasted_ipow(self, xp, x_type, y_type):
a = xp.array([[1, 2, 3], [4, 5, 6]], x_type)
b = xp.array([[1], [2]], y_type)
return operator.ipow(a, b)
示例5: test_inplace_exponentiation
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def test_inplace_exponentiation(self, input_tuple, expected):
self.ureg.default_as_delta = False
in1, in2 = input_tuple
if type(in1) is tuple and type(in2) is tuple:
(q1v, q1u), (q2v, q2u) = in1, in2
in1 = self.Q_(*(np.array([q1v]*2, dtype=np.float), q1u))
in2 = self.Q_(q2v, q2u)
elif not type(in1) is tuple and type(in2) is tuple:
in2 = self.Q_(*in2)
else:
in1 = self.Q_(*in1)
input_tuple = in1, in2
expected_copy = expected[:]
for i, mode in enumerate([False, True]):
self.ureg.autoconvert_offset_to_baseunit = mode
in1_cp = copy.copy(in1)
if expected_copy[i] == 'error':
self.assertRaises((OffsetUnitCalculusError,
DimensionalityError), op.ipow, in1_cp, in2)
else:
if type(expected_copy[i]) is tuple:
expected = self.Q_(np.array([expected_copy[i][0]]*2,
dtype=np.float),
expected_copy[i][1])
self.assertEqual(op.ipow(in1_cp, in2).units, expected.units)
else:
expected = np.array([expected_copy[i]]*2, dtype=np.float)
in1_cp = copy.copy(in1)
self.assertQuantityAlmostEqual(op.ipow(in1_cp, in2), expected)
示例6: test_exponentiation_array_exp
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def test_exponentiation_array_exp(self):
arr = np.array(range(3), dtype=np.float)
q = self.Q_(arr, None)
for op_ in [op.pow, op.ipow]:
q_cp = copy.copy(q)
self.assertRaises(DimensionalityError, op_, 2., q_cp)
arr_cp = copy.copy(arr)
arr_cp = copy.copy(arr)
q_cp = copy.copy(q)
self.assertRaises(DimensionalityError, op_, q_cp, arr_cp)
q_cp = copy.copy(q)
q2_cp = copy.copy(q)
self.assertRaises(DimensionalityError, op_, q_cp, q2_cp)
示例7: test_exponentiation_array_exp_2
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def test_exponentiation_array_exp_2(self):
arr = np.array(range(3), dtype=np.float)
#q = self.Q_(copy.copy(arr), None)
q = self.Q_(copy.copy(arr), 'meter')
arr_cp = copy.copy(arr)
q_cp = copy.copy(q)
# this fails as expected since numpy 1.8.0 but...
self.assertRaises(DimensionalityError, op.pow, arr_cp, q_cp)
# ..not for op.ipow !
# q_cp is treated as if it is an array. The units are ignored.
# _Quantity.__ipow__ is never called
arr_cp = copy.copy(arr)
q_cp = copy.copy(q)
self.assertRaises(DimensionalityError, op.ipow, arr_cp, q_cp)
示例8: test_unitcontainer_arithmetic
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def test_unitcontainer_arithmetic(self):
x = UnitsContainer(meter=1)
y = UnitsContainer(second=1)
z = UnitsContainer(meter=1, second=-2)
self._test_not_inplace(op.mul, x, y, UnitsContainer(meter=1, second=1))
self._test_not_inplace(op.truediv, x, y, UnitsContainer(meter=1, second=-1))
self._test_not_inplace(op.pow, z, 2, UnitsContainer(meter=2, second=-4))
self._test_not_inplace(op.pow, z, -2, UnitsContainer(meter=-2, second=4))
self._test_inplace(op.imul, x, y, UnitsContainer(meter=1, second=1))
self._test_inplace(op.itruediv, x, y, UnitsContainer(meter=1, second=-1))
self._test_inplace(op.ipow, z, 2, UnitsContainer(meter=2, second=-4))
self._test_inplace(op.ipow, z, -2, UnitsContainer(meter=-2, second=4))
示例9: __ipow__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def __ipow__(self, other):
return Expression((self, other), operator.ipow)
示例10: __ipow__
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [as 別名]
def __ipow__(self, other, *args):
return operator.ipow(self._wrapped(), other, *args)
示例11: test_inplace
# 需要導入模塊: import operator [as 別名]
# 或者: from operator import ipow [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")