本文整理汇总了Python中numpy.core._rational_tests.test_add方法的典型用法代码示例。如果您正苦于以下问题:Python _rational_tests.test_add方法的具体用法?Python _rational_tests.test_add怎么用?Python _rational_tests.test_add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类numpy.core._rational_tests
的用法示例。
在下文中一共展示了_rational_tests.test_add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_ufunc_custom_out
# 需要导入模块: from numpy.core import _rational_tests [as 别名]
# 或者: from numpy.core._rational_tests import test_add [as 别名]
def test_ufunc_custom_out(self):
# Test ufunc with built in input types and custom output type
a = np.array([0, 1, 2], dtype='i8')
b = np.array([0, 1, 2], dtype='i8')
c = np.empty(3, dtype=_rational_tests.rational)
# Output must be specified so numpy knows what
# ufunc signature to look for
result = _rational_tests.test_add(a, b, c)
target = np.array([0, 2, 4], dtype=_rational_tests.rational)
assert_equal(result, target)
# no output type should raise TypeError
with assert_raises(TypeError):
_rational_tests.test_add(a, b)
示例2: test_pickle
# 需要导入模块: from numpy.core import _rational_tests [as 别名]
# 或者: from numpy.core._rational_tests import test_add [as 别名]
def test_pickle(self):
for proto in range(2, pickle.HIGHEST_PROTOCOL + 1):
assert_(pickle.loads(pickle.dumps(np.sin,
protocol=proto)) is np.sin)
# Check that ufunc not defined in the top level numpy namespace
# such as numpy.core._rational_tests.test_add can also be pickled
res = pickle.loads(pickle.dumps(_rational_tests.test_add,
protocol=proto))
assert_(res is _rational_tests.test_add)
示例3: test_pickle
# 需要导入模块: from numpy.core import _rational_tests [as 别名]
# 或者: from numpy.core._rational_tests import test_add [as 别名]
def test_pickle(self):
import pickle
assert_(pickle.loads(pickle.dumps(np.sin)) is np.sin)
# Check that ufunc not defined in the top level numpy namespace such as
# numpy.core._rational_tests.test_add can also be pickled
res = pickle.loads(pickle.dumps(_rational_tests.test_add))
assert_(res is _rational_tests.test_add)