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


Python operator.div方法代码示例

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


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

示例1: _add_arithmetic_ops

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def _add_arithmetic_ops(cls):
        cls.__add__ = cls._create_arithmetic_method(operator.add)
        cls.__radd__ = cls._create_arithmetic_method(ops.radd)
        cls.__sub__ = cls._create_arithmetic_method(operator.sub)
        cls.__rsub__ = cls._create_arithmetic_method(ops.rsub)
        cls.__mul__ = cls._create_arithmetic_method(operator.mul)
        cls.__rmul__ = cls._create_arithmetic_method(ops.rmul)
        cls.__pow__ = cls._create_arithmetic_method(operator.pow)
        cls.__rpow__ = cls._create_arithmetic_method(ops.rpow)
        cls.__mod__ = cls._create_arithmetic_method(operator.mod)
        cls.__rmod__ = cls._create_arithmetic_method(ops.rmod)
        cls.__floordiv__ = cls._create_arithmetic_method(operator.floordiv)
        cls.__rfloordiv__ = cls._create_arithmetic_method(ops.rfloordiv)
        cls.__truediv__ = cls._create_arithmetic_method(operator.truediv)
        cls.__rtruediv__ = cls._create_arithmetic_method(ops.rtruediv)
        if not PY3:
            cls.__div__ = cls._create_arithmetic_method(operator.div)
            cls.__rdiv__ = cls._create_arithmetic_method(ops.rdiv)

        cls.__divmod__ = cls._create_arithmetic_method(divmod)
        cls.__rdivmod__ = cls._create_arithmetic_method(ops.rdivmod) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:23,代码来源:base.py

示例2: _add_numeric_methods_binary

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def _add_numeric_methods_binary(cls):
        """
        Add in numeric methods.
        """
        cls.__add__ = _make_arithmetic_op(operator.add, cls)
        cls.__radd__ = _make_arithmetic_op(ops.radd, cls)
        cls.__sub__ = _make_arithmetic_op(operator.sub, cls)
        cls.__rsub__ = _make_arithmetic_op(ops.rsub, cls)
        cls.__rpow__ = _make_arithmetic_op(ops.rpow, cls)
        cls.__pow__ = _make_arithmetic_op(operator.pow, cls)

        cls.__truediv__ = _make_arithmetic_op(operator.truediv, cls)
        cls.__rtruediv__ = _make_arithmetic_op(ops.rtruediv, cls)
        if not compat.PY3:
            cls.__div__ = _make_arithmetic_op(operator.div, cls)
            cls.__rdiv__ = _make_arithmetic_op(ops.rdiv, cls)

        # TODO: rmod? rdivmod?
        cls.__mod__ = _make_arithmetic_op(operator.mod, cls)
        cls.__floordiv__ = _make_arithmetic_op(operator.floordiv, cls)
        cls.__rfloordiv__ = _make_arithmetic_op(ops.rfloordiv, cls)
        cls.__divmod__ = _make_arithmetic_op(divmod, cls)
        cls.__mul__ = _make_arithmetic_op(operator.mul, cls)
        cls.__rmul__ = _make_arithmetic_op(ops.rmul, cls) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:26,代码来源:base.py

示例3: test_op_method

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def test_op_method(self, opname, ts):
        # check that Series.{opname} behaves like Series.__{opname}__,
        series = ts[0](self.ts)
        other = ts[1](self.ts)
        check_reverse = ts[2]

        if opname == 'div' and compat.PY3:
            pytest.skip('div test only for Py3')

        op = getattr(Series, opname)

        if op == 'div':
            alt = operator.truediv
        else:
            alt = getattr(operator, opname)

        result = op(series, other)
        expected = alt(series, other)
        assert_almost_equal(result, expected)
        if check_reverse:
            rop = getattr(Series, "r" + opname)
            result = rop(series, other)
            expected = alt(other, series)
            assert_almost_equal(result, expected) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:26,代码来源:test_operators.py

示例4: _add_numeric_methods_binary

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def _add_numeric_methods_binary(cls):
        """ add in numeric methods """
        cls.__add__ = _make_arithmetic_op(operator.add, cls)
        cls.__radd__ = _make_arithmetic_op(ops.radd, cls)
        cls.__sub__ = _make_arithmetic_op(operator.sub, cls)
        cls.__rsub__ = _make_arithmetic_op(ops.rsub, cls)
        cls.__mul__ = _make_arithmetic_op(operator.mul, cls)
        cls.__rmul__ = _make_arithmetic_op(ops.rmul, cls)
        cls.__rpow__ = _make_arithmetic_op(ops.rpow, cls)
        cls.__pow__ = _make_arithmetic_op(operator.pow, cls)
        cls.__mod__ = _make_arithmetic_op(operator.mod, cls)
        cls.__floordiv__ = _make_arithmetic_op(operator.floordiv, cls)
        cls.__rfloordiv__ = _make_arithmetic_op(ops.rfloordiv, cls)
        cls.__truediv__ = _make_arithmetic_op(operator.truediv, cls)
        cls.__rtruediv__ = _make_arithmetic_op(ops.rtruediv, cls)
        if not compat.PY3:
            cls.__div__ = _make_arithmetic_op(operator.div, cls)
            cls.__rdiv__ = _make_arithmetic_op(ops.rdiv, cls)

        cls.__divmod__ = _make_arithmetic_op(divmod, cls) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:22,代码来源:base.py

示例5: __div__

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

示例6: __rdiv__

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

示例7: __div__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def __div__(self, other):
        assert type(other) in (int, long, float)
        return Vector2(operator.div(self.x, other),
                       operator.div(self.y, other)) 
开发者ID:ladybug-tools,项目名称:honeybee,代码行数:6,代码来源:euclid.py

示例8: __rdiv__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def __rdiv__(self, other):
        assert type(other) in (int, long, float)
        return Vector2(operator.div(other, self.x),
                       operator.div(other, self.y)) 
开发者ID:ladybug-tools,项目名称:honeybee,代码行数:6,代码来源:euclid.py

示例9: __mul__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def __mul__(self, other):
        if isinstance(other, Vector3):
            # TODO component-wise mul/div in-place and on Vector2; docs.
            if self.__class__ is Point3 or other.__class__ is Point3:
                _class = Point3
            else:
                _class = Vector3
            return _class(self.x * other.x,
                          self.y * other.y,
                          self.z * other.z)
        else:
            assert type(other) in (int, long, float)
            return Vector3(self.x * other,
                           self.y * other,
                           self.z * other) 
开发者ID:ladybug-tools,项目名称:honeybee,代码行数:17,代码来源:euclid.py

示例10: test_int_dtypes

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def test_int_dtypes(self):
        #scramble types and do some mix and match testing
        deprecated_types = [
           'bool_', 'int_', 'intc', 'uint8', 'int8', 'uint64', 'int32', 'uint16',
           'intp', 'int64', 'uint32', 'int16'
            ]
        if sys.version_info[0] < 3 and sys.py3kwarning:
            import operator as op
            dt2 = 'bool_'
            for dt1 in deprecated_types:
                a = np.array([1,2,3], dtype=dt1)
                b = np.array([1,2,3], dtype=dt2)
                self.assert_deprecated(op.div, args=(a,b))
                dt2 = dt1 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:16,代码来源:test_deprecations.py

示例11: dispatch_missing

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def dispatch_missing(op, left, right, result):
    """
    Fill nulls caused by division by zero, casting to a diffferent dtype
    if necessary.

    Parameters
    ----------
    op : function (operator.add, operator.div, ...)
    left : object (Index for non-reversed ops)
    right : object (Index fof reversed ops)
    result : ndarray

    Returns
    -------
    result : ndarray
    """
    opstr = '__{opname}__'.format(opname=op.__name__).replace('____', '__')
    if op in [operator.truediv, operator.floordiv,
              getattr(operator, 'div', None)]:
        result = mask_zero_div_zero(left, right, result)
    elif op is operator.mod:
        result = fill_zeros(result, left, right, opstr, np.nan)
    elif op is divmod:
        res0 = mask_zero_div_zero(left, right, result[0])
        res1 = fill_zeros(result[1], left, right, opstr, np.nan)
        result = (res0, res1)
    return result 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:29,代码来源:missing.py

示例12: __rdiv__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def __rdiv__(self, other):
        """Implement the ``/`` operator in reverse.

        See :meth:`.ColumnOperators.__div__`.

        """
        return self.reverse_operate(div, other) 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:operators.py

示例13: __div__

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def __div__(self, other):
        """Implement the ``/`` operator.

        In a column context, produces the clause ``a / b``.

        """
        return self.operate(div, other) 
开发者ID:jpush,项目名称:jbox,代码行数:9,代码来源:operators.py

示例14: test_div_method

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def test_div_method(self):
        self.defined_method_test("div", "div-method") 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:4,代码来源:unittest_checker_python3.py

示例15: test_bad_operator_attribute

# 需要导入模块: import operator [as 别名]
# 或者: from operator import div [as 别名]
def test_bad_operator_attribute(self):
        node = astroid.extract_node(
            """
        import operator
        operator.div #@
        """
        )
        message = testutils.Message("deprecated-operator-function", node=node)
        with self.assertAddsMessages(message):
            self.checker.visit_attribute(node) 
开发者ID:sofia-netsurv,项目名称:python-netsurv,代码行数:12,代码来源:unittest_checker_python3.py


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