本文整理匯總了Python中numpy.core._multiarray_tests.extint_safe_binop方法的典型用法代碼示例。如果您正苦於以下問題:Python _multiarray_tests.extint_safe_binop方法的具體用法?Python _multiarray_tests.extint_safe_binop怎麽用?Python _multiarray_tests.extint_safe_binop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類numpy.core._multiarray_tests
的用法示例。
在下文中一共展示了_multiarray_tests.extint_safe_binop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_safe_binop
# 需要導入模塊: from numpy.core import _multiarray_tests [as 別名]
# 或者: from numpy.core._multiarray_tests import extint_safe_binop [as 別名]
def test_safe_binop():
# Test checked arithmetic routines
ops = [
(operator.add, 1),
(operator.sub, 2),
(operator.mul, 3)
]
with exc_iter(ops, INT64_VALUES, INT64_VALUES) as it:
for xop, a, b in it:
pyop, op = xop
c = pyop(a, b)
if not (INT64_MIN <= c <= INT64_MAX):
assert_raises(OverflowError, mt.extint_safe_binop, a, b, op)
else:
d = mt.extint_safe_binop(a, b, op)
if c != d:
# assert_equal is slow
assert_equal(d, c)