本文整理汇总了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)))
示例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,)})
示例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)))
示例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,)})
示例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], {})
示例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], {})
示例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')
示例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)
示例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)
示例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)))