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


Python umath.multiply方法代码示例

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


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

示例1: test_wrap_with_iterable

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_wrap_with_iterable(self):
        # test fix for bug #1026:

        class with_wrap(np.ndarray):
            __array_priority__ = 10

            def __new__(cls):
                return np.asarray(1).view(cls).copy()

            def __array_wrap__(self, arr, context):
                return arr.view(type(self))

        a = with_wrap()
        x = ncu.multiply(a, (1, 2, 3))
        assert_(isinstance(x, with_wrap))
        assert_array_equal(x, np.array((1, 2, 3))) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:test_umath.py

示例2: test_ufunc_override

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_ufunc_override(self):
        # check override works even with instance with high priority.
        class A(object):
            def __array_ufunc__(self, func, method, *inputs, **kwargs):
                return self, func, method, inputs, kwargs

        class MyNDArray(np.ndarray):
            __array_priority__ = 100

        a = A()
        b = np.array([1]).view(MyNDArray)
        res0 = np.multiply(a, b)
        res1 = np.multiply(b, b, out=a)

        # self
        assert_equal(res0[0], a)
        assert_equal(res1[0], a)
        assert_equal(res0[1], np.multiply)
        assert_equal(res1[1], np.multiply)
        assert_equal(res0[2], '__call__')
        assert_equal(res1[2], '__call__')
        assert_equal(res0[3], (a, b))
        assert_equal(res1[3], (b, b))
        assert_equal(res0[4], {})
        assert_equal(res1[4], {'out': (a,)}) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:test_umath.py

示例3: test_wrap_with_iterable

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_wrap_with_iterable(self):
        # test fix for bug #1026:

        class with_wrap(np.ndarray):
            __array_priority__ = 10

            def __new__(cls):
                return np.asarray(1).view(cls).copy()

            def __array_wrap__(self, arr, context):
                return arr.view(type(self))

        a = with_wrap()
        x = ncu.multiply(a, (1, 2, 3))
        self.assertTrue(isinstance(x, with_wrap))
        assert_array_equal(x, np.array((1, 2, 3))) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:18,代码来源:test_umath.py

示例4: test_ufunc_override

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_ufunc_override(self):

        class A(object):
            def __array_ufunc__(self, func, method, *inputs, **kwargs):
                return self, func, method, inputs, kwargs

        a = A()
        b = np.matrix([1])
        res0 = np.multiply(a, b)
        res1 = np.multiply(b, b, out=a)

        # self
        assert_equal(res0[0], a)
        assert_equal(res1[0], a)
        assert_equal(res0[1], np.multiply)
        assert_equal(res1[1], np.multiply)
        assert_equal(res0[2], '__call__')
        assert_equal(res1[2], '__call__')
        assert_equal(res0[3], (a, b))
        assert_equal(res1[3], (b, b))
        assert_equal(res0[4], {})
        assert_equal(res1[4], {'out': (a,)}) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:24,代码来源:test_umath.py

示例5: test_ufunc_override

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_ufunc_override(self):
        class A(object):
            def __numpy_ufunc__(self, func, method, pos, inputs, **kwargs):
                return self, func, method, pos, inputs, kwargs

        a = A()

        b = np.matrix([1])
        c = np.array([1])
        res0 = np.multiply(a, b)
        res1 = np.dot(a, b)

        # self
        assert_equal(res0[0], a)
        assert_equal(res1[0], a)
        assert_equal(res0[1], np.multiply)
        assert_equal(res1[1], np.dot)
        assert_equal(res0[2], '__call__')
        assert_equal(res1[2], '__call__')
        assert_equal(res0[3], 0)
        assert_equal(res1[3], 0)
        assert_equal(res0[4], (a, b))
        assert_equal(res1[4], (a, b))
        assert_equal(res0[5], {})
        assert_equal(res1[5], {}) 
开发者ID:pfchai,项目名称:ImageFusion,代码行数:27,代码来源:test_umath.py

示例6: test_ufunc_override

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_ufunc_override(self):
        # 2016-01-29: NUMPY_UFUNC_DISABLED
        return

        class A(object):
            def __numpy_ufunc__(self, func, method, pos, inputs, **kwargs):
                return self, func, method, pos, inputs, kwargs

        a = A()
        b = np.matrix([1])
        res0 = np.multiply(a, b)
        res1 = np.dot(a, b)

        # self
        assert_equal(res0[0], a)
        assert_equal(res1[0], a)
        assert_equal(res0[1], np.multiply)
        assert_equal(res1[1], np.dot)
        assert_equal(res0[2], '__call__')
        assert_equal(res1[2], '__call__')
        assert_equal(res0[3], 0)
        assert_equal(res1[3], 0)
        assert_equal(res0[4], (a, b))
        assert_equal(res1[4], (a, b))
        assert_equal(res0[5], {})
        assert_equal(res1[5], {}) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:28,代码来源:test_umath.py

示例7: test_ufunc_override_out

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_ufunc_override_out(self):
        # 2016-01-29: NUMPY_UFUNC_DISABLED
        return

        class A(object):
            def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
                return kwargs

        class B(object):
            def __numpy_ufunc__(self, ufunc, method, pos, inputs, **kwargs):
                return kwargs

        a = A()
        b = B()
        res0 = np.multiply(a, b, 'out_arg')
        res1 = np.multiply(a, b, out='out_arg')
        res2 = np.multiply(2, b, 'out_arg')
        res3 = np.multiply(3, b, out='out_arg')
        res4 = np.multiply(a, 4, 'out_arg')
        res5 = np.multiply(a, 5, out='out_arg')

        assert_equal(res0['out'], 'out_arg')
        assert_equal(res1['out'], 'out_arg')
        assert_equal(res2['out'], 'out_arg')
        assert_equal(res3['out'], 'out_arg')
        assert_equal(res4['out'], 'out_arg')
        assert_equal(res5['out'], 'out_arg')

        # ufuncs with multiple output modf and frexp.
        res6 = np.modf(a, 'out0', 'out1')
        res7 = np.frexp(a, 'out0', 'out1')
        assert_equal(res6['out'][0], 'out0')
        assert_equal(res6['out'][1], 'out1')
        assert_equal(res7['out'][0], 'out0')
        assert_equal(res7['out'][1], 'out1') 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:37,代码来源:test_umath.py

示例8: __mul__

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def __mul__(self, other):
        "Return multiply(self, other)"
        return multiply(self, other) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:5,代码来源:ma.py

示例9: product

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def product (target, axis=None, dtype=None):
    if axis is None:
        target = ravel(target)
        axis = 0
    return multiply.reduce(target, axis, dtype) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:ma.py

示例10: test_wrap_with_iterable

# 需要导入模块: from numpy.core import umath [as 别名]
# 或者: from numpy.core.umath import multiply [as 别名]
def test_wrap_with_iterable(self):
        # test fix for bug #1026:
        class with_wrap(np.ndarray):
            __array_priority__ = 10
            def __new__(cls):
                return np.asarray(1).view(cls).copy()
            def __array_wrap__(self, arr, context):
                return arr.view(type(self))
        a = with_wrap()
        x = ncu.multiply(a, (1, 2, 3))
        self.assertTrue(isinstance(x, with_wrap))
        assert_array_equal(x, np.array((1, 2, 3))) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:14,代码来源:test_umath.py


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