当前位置: 首页>>代码示例>>Python>>正文


Python operator.isub方法代码示例

本文整理汇总了Python中operator.isub方法的典型用法代码示例。如果您正苦于以下问题:Python operator.isub方法的具体用法?Python operator.isub怎么用?Python operator.isub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在operator的用法示例。


在下文中一共展示了operator.isub方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _test_quantity_iadd_isub

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def _test_quantity_iadd_isub(self, unit, func):
        x = self.Q_(unit, 'centimeter')
        y = self.Q_(unit, 'inch')
        z = self.Q_(unit, 'second')
        a = self.Q_(unit, None)

        func(op.iadd, x, x, self.Q_(unit + unit, 'centimeter'))
        func(op.iadd, x, y, self.Q_(unit + 2.54 * unit, 'centimeter'))
        func(op.iadd, y, x, self.Q_(unit + unit / 2.54, 'inch'))
        func(op.iadd, a, unit, self.Q_(unit + unit, None))
        self.assertRaises(DimensionalityError, op.iadd, 10, x)
        self.assertRaises(DimensionalityError, op.iadd, x, 10)
        self.assertRaises(DimensionalityError, op.iadd, x, z)

        func(op.isub, x, x, self.Q_(unit - unit, 'centimeter'))
        func(op.isub, x, y, self.Q_(unit - 2.54, 'centimeter'))
        func(op.isub, y, x, self.Q_(unit - unit / 2.54, 'inch'))
        func(op.isub, a, unit, self.Q_(unit - unit, None))
        self.assertRaises(DimensionalityError, op.sub, 10, x)
        self.assertRaises(DimensionalityError, op.sub, x, 10)
        self.assertRaises(DimensionalityError, op.sub, x, z) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:23,代码来源:test_quantity.py

示例2: test_inplace_subtraction

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def test_inplace_subtraction(self, input_tuple, expected):
        self.ureg.autoconvert_offset_to_baseunit = False
        (q1v, q1u), (q2v, q2u) = input_tuple
        # update input tuple with new values to have correct values on failure
        input_tuple = ((np.array([q1v]*2, dtype=np.float), q1u),
                       (np.array([q2v]*2, dtype=np.float), q2u))
        Q_ = self.Q_
        qin1, qin2 = input_tuple
        q1, q2 = Q_(*qin1), Q_(*qin2)
        q1_cp = copy.copy(q1)
        if expected == 'error':
            self.assertRaises(OffsetUnitCalculusError, op.isub, q1_cp, q2)
        else:
            expected = np.array([expected[0]]*2, dtype=np.float), expected[1]
            self.assertEqual(op.isub(q1_cp, q2).units, Q_(*expected).units)
            q1_cp = copy.copy(q1)
            self.assertQuantityAlmostEqual(op.isub(q1_cp, q2), Q_(*expected),
                                           atol=0.01) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:20,代码来源:test_quantity.py

示例3: test_operatorerrors

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def test_operatorerrors(self):
        f2 = self.f2
        f2p = self.f2p
        f256 = self.f256
        f19 = self.f19
        self.assertRaises(TypeError, operator.add, f2(1), f2p(2))
        self.assertRaises(TypeError, operator.iadd, f2(1), f2p(2))
        self.assertRaises(TypeError, operator.sub, f2(1), f256(2))
        self.assertRaises(TypeError, operator.isub, f2(1), f256(2))
        self.assertRaises(TypeError, operator.mul, f2(1), f19(2))
        self.assertRaises(TypeError, operator.imul, f2(1), f19(2))
        self.assertRaises(TypeError, operator.truediv, f256(1), f19(2))
        self.assertRaises(TypeError, operator.itruediv, f256(1), f19(2))
        self.assertRaises(TypeError, operator.truediv, 3.14, f19(2))
        self.assertRaises(TypeError, operator.lshift, f2(1), f2(1))
        self.assertRaises(TypeError, operator.ilshift, f2(1), f2(1))
        self.assertRaises(TypeError, operator.lshift, 1, f2(1))
        self.assertRaises(TypeError, operator.rshift, f19(1), f19(1))
        self.assertRaises(TypeError, operator.irshift, f19(1), f19(1))
        self.assertRaises(TypeError, operator.irshift, f256(1), f256(1))
        self.assertRaises(TypeError, operator.pow, f2(1), f19(2))
        self.assertRaises(TypeError, operator.pow, f19(1), 3.14) 
开发者ID:lschoe,项目名称:mpyc,代码行数:24,代码来源:test_finfields.py

示例4: remove_const_BG_preedge

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def remove_const_BG_preedge(
    xmcd_data, scanparams, process_parameters=None, process_number=-1
):
    """Should remove a constant bg based on the preedge average (might be one,
    if the data is normalized to preedge)"""
    return calculate_xas_xmcd(process_parameters, xmcd_data, operator.isub) 
开发者ID:materialsproject,项目名称:MPContribs,代码行数:8,代码来源:xas_process.py

示例5: testISub

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def testISub(self):
        self.augmentedAssignCheck(operator.isub) 
开发者ID:myhdl,项目名称:myhdl,代码行数:4,代码来源:test_Signal.py

示例6: __isub__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def __isub__(self, other: Union['Quantity', float, int]) -> 'Quantity':
        return Quantity._math_operation(self, other, operator.isub) 
开发者ID:tensortrade-org,项目名称:tensortrade,代码行数:4,代码来源:quantity.py

示例7: test_isub_scalar

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def test_isub_scalar(self):
        self.check_array_scalar_op(operator.isub, no_bool=True) 
开发者ID:cupy,项目名称:cupy,代码行数:4,代码来源:test_ndarray_elementwise_op.py

示例8: test_isub_array

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def test_isub_array(self):
        self.check_array_array_op(operator.isub, no_bool=True) 
开发者ID:cupy,项目名称:cupy,代码行数:4,代码来源:test_ndarray_elementwise_op.py

示例9: test_broadcasted_isub

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def test_broadcasted_isub(self):
        # TODO(unno): sub for boolean array is deprecated in numpy>=1.13
        self.check_array_broadcasted_op(operator.isub, no_bool=True) 
开发者ID:cupy,项目名称:cupy,代码行数:5,代码来源:test_ndarray_elementwise_op.py

示例10: test_issue52

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [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) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:14,代码来源:test_issues.py

示例11: __isub__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def __isub__(self, other):
        if not isinstance(self._magnitude, ndarray):
            return self._add_sub(other, operator.sub)
        else:
            return self._iadd_sub(other, operator.isub) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:7,代码来源:quantity.py

示例12: test_difference_update_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def test_difference_update_operator(self):  # test -= operator
        self.assertSingleValueOperator(lambda s, o: operator.isub(s, o))
        self.assertMultipleValuesOperator(
            lambda s, o: operator.isub(s, functools.reduce(operator.sub, [t.copy() for t in o]))) 
开发者ID:mathiasertl,项目名称:django-ca,代码行数:6,代码来源:tests_extensions.py

示例13: __isub__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def __isub__(self, other):
        return self._operation(other, operator.isub) 
开发者ID:typemytype,项目名称:GlyphConstruction,代码行数:4,代码来源:glyphConstruction.py

示例14: _test_errors

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [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) 
开发者ID:lschoe,项目名称:mpyc,代码行数:37,代码来源:test_gfpx.py

示例15: __isub__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import isub [as 别名]
def __isub__(self, other):
        return Expression((self, other), operator.isub) 
开发者ID:ebranca,项目名称:owasp-pysec,代码行数:4,代码来源:expr.py


注:本文中的operator.isub方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。