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


Python operator.itruediv方法代码示例

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


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

示例1: add_globals

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def add_globals(self):
    "Add some Scheme standard procedures."
    import math, cmath, operator as op
    from functools import reduce
    self.update(vars(math))
    self.update(vars(cmath))
    self.update({
     '+':op.add, '-':op.sub, '*':op.mul, '/':op.itruediv, 'níl':op.not_, 'agus':op.and_,
     '>':op.gt, '<':op.lt, '>=':op.ge, '<=':op.le, '=':op.eq, 'mod':op.mod, 
     'frmh':cmath.sqrt, 'dearbhluach':abs, 'uas':max, 'íos':min,
     'cothrom_le?':op.eq, 'ionann?':op.is_, 'fad':len, 'cons':cons,
     'ceann':lambda x:x[0], 'tóin':lambda x:x[1:], 'iarcheangail':op.add,  
     'liosta':lambda *x:list(x), 'liosta?': lambda x:isa(x,list),
     'folamh?':lambda x: x == [], 'adamh?':lambda x: not((isa(x, list)) or (x == None)),
     'boole?':lambda x: isa(x, bool), 'scag':lambda f, x: list(filter(f, x)),
     'cuir_le':lambda proc,l: proc(*l), 'mapáil':lambda p, x: list(map(p, x)), 
     'lódáil':lambda fn: load(fn), 'léigh':lambda f: f.read(),
     'oscail_comhad_ionchuir':open,'dún_comhad_ionchuir':lambda p: p.file.close(), 
     'oscail_comhad_aschur':lambda f:open(f,'w'), 'dún_comhad_aschur':lambda p: p.close(),
     'dac?':lambda x:x is eof_object, 'luacháil':lambda x: evaluate(x),
     'scríobh':lambda x,port=sys.stdout:port.write(to_string(x) + '\n')})
    return self 
开发者ID:neal-o-r,项目名称:aireamhan,代码行数:24,代码来源:__init__.py

示例2: test_inplace_truedivision

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def test_inplace_truedivision(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.itruediv, q1_cp, q2)
        else:
            expected = np.array([expected[0]]*2, dtype=np.float), expected[1]
            self.assertEqual(op.itruediv(q1_cp, q2).units, Q_(*expected).units)
            q1_cp = copy.copy(q1)
            self.assertQuantityAlmostEqual(op.itruediv(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 itruediv [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: __itruediv__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def __itruediv__(self, other):
        self.__wrapped__ = operator.itruediv(self.__wrapped__, other)
        return self 
开发者ID:danielecook,项目名称:gist-alfred,代码行数:5,代码来源:wrappers.py

示例5: test_itruediv_scalar

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def test_itruediv_scalar(self):
        with testing.NumpyError(divide='ignore'):
            self.check_array_scalar_op(operator.itruediv) 
开发者ID:cupy,项目名称:cupy,代码行数:5,代码来源:test_ndarray_elementwise_op.py

示例6: test_itruediv_array

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def test_itruediv_array(self):
        with testing.NumpyError(divide='ignore'):
            self.check_array_array_op(operator.itruediv) 
开发者ID:cupy,项目名称:cupy,代码行数:5,代码来源:test_ndarray_elementwise_op.py

示例7: test_broadcasted_itruediv

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def test_broadcasted_itruediv(self):
        with testing.NumpyError(divide='ignore'):
            self.check_array_broadcasted_op(operator.itruediv) 
开发者ID:cupy,项目名称:cupy,代码行数:5,代码来源:test_ndarray_elementwise_op.py

示例8: _test_quantity_imul_idiv

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def _test_quantity_imul_idiv(self, unit, func):
        #func(op.imul, 10.0, '4.2*meter', '42*meter')
        func(op.imul, '4.2*meter', 10.0, '42*meter', unit)
        func(op.imul, '4.2*meter', '10*inch', '42*meter*inch', unit)
        #func(op.truediv, 42, '4.2*meter', '10/meter')
        func(op.itruediv, '4.2*meter', unit * 10.0, '0.42*meter', unit)
        func(op.itruediv, '4.2*meter', '10*inch', '0.42*meter/inch', unit) 
开发者ID:jmwright,项目名称:cadquery-freecad-module,代码行数:9,代码来源:test_quantity.py

示例9: test_issue52

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [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

示例10: test_unitcontainer_arithmetic

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

示例11: __itruediv__

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

示例12: __itruediv__

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

示例13: __itruediv__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def __itruediv__(self, other):
        return operator.itruediv(self._wrapped(), other) 
开发者ID:pschanely,项目名称:CrossHair,代码行数:4,代码来源:objectproxy.py

示例14: test_scalar_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def test_scalar_operator(tspace, odl_arithmetic_op):
    """Verify binary operations with scalars.

    Verifies that the statement y = op(x, scalar) gives equivalent results
    to NumPy.
    """
    op = odl_arithmetic_op
    if op in (operator.truediv, operator.itruediv):
        ndigits = int(-np.log10(np.finfo(tspace.dtype).resolution) // 2)
    else:
        ndigits = int(-np.log10(np.finfo(tspace.dtype).resolution))

    for scalar in [-31.2, -1, 0, 1, 2.13]:
        x_arr, x = noise_elements(tspace)

        # Left op
        if scalar == 0 and op in [operator.truediv, operator.itruediv]:
            # Check for correct zero division behaviour
            with pytest.raises(ZeroDivisionError):
                y = op(x, scalar)
        else:
            y_arr = op(x_arr, scalar)
            y = op(x, scalar)

            assert all_almost_equal([x, y], [x_arr, y_arr], ndigits)

        # right op
        x_arr, x = noise_elements(tspace)

        y_arr = op(scalar, x_arr)
        y = op(scalar, x)

        assert all_almost_equal([x, y], [x_arr, y_arr], ndigits) 
开发者ID:odlgroup,项目名称:odl,代码行数:35,代码来源:tensors_test.py

示例15: test_binary_operator

# 需要导入模块: import operator [as 别名]
# 或者: from operator import itruediv [as 别名]
def test_binary_operator(tspace, odl_arithmetic_op):
    """Verify binary operations with tensors.

    Verifies that the statement z = op(x, y) gives equivalent results
    to NumPy.
    """
    op = odl_arithmetic_op
    if op in (operator.truediv, operator.itruediv):
        ndigits = int(-np.log10(np.finfo(tspace.dtype).resolution) // 2)
    else:
        ndigits = int(-np.log10(np.finfo(tspace.dtype).resolution))

    [x_arr, y_arr], [x, y] = noise_elements(tspace, 2)

    # non-aliased left
    z_arr = op(x_arr, y_arr)
    z = op(x, y)

    assert all_almost_equal([x, y, z], [x_arr, y_arr, z_arr], ndigits)

    # non-aliased right
    z_arr = op(y_arr, x_arr)
    z = op(y, x)

    assert all_almost_equal([x, y, z], [x_arr, y_arr, z_arr], ndigits)

    # aliased operation
    z_arr = op(x_arr, x_arr)
    z = op(x, x)

    assert all_almost_equal([x, y, z], [x_arr, y_arr, z_arr], ndigits) 
开发者ID:odlgroup,项目名称:odl,代码行数:33,代码来源:tensors_test.py


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