MCPcopy Create free account
hub / github.com/numpy/numpy / test_safe_binop

Function test_safe_binop

numpy/core/tests/test_extint128.py:66–86  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64
65
66def test_safe_binop():
67 # Test checked arithmetic routines
68
69 ops = [
70 (operator.add, 1),
71 (operator.sub, 2),
72 (operator.mul, 3)
73 ]
74
75 with exc_iter(ops, INT64_VALUES, INT64_VALUES) as it:
76 for xop, a, b in it:
77 pyop, op = xop
78 c = pyop(a, b)
79
80 if not (INT64_MIN <= c <= INT64_MAX):
81 assert_raises(OverflowError, mt.extint_safe_binop, a, b, op)
82 else:
83 d = mt.extint_safe_binop(a, b, op)
84 if c != d:
85 # assert_equal is slow
86 assert_equal(d, c)
87
88
89def test_to_128():

Callers

nothing calls this directly

Calls 3

assert_raisesFunction · 0.90
assert_equalFunction · 0.90
exc_iterFunction · 0.85

Tested by

no test coverage detected