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

Method test_remainder_basic

numpy/core/tests/test_umath.py:708–722  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

706class TestRemainder:
707
708 def test_remainder_basic(self):
709 dt = np.typecodes['AllInteger'] + np.typecodes['Float']
710 for op in [floor_divide_and_remainder, np.divmod]:
711 for dt1, dt2 in itertools.product(dt, dt):
712 for sg1, sg2 in itertools.product(_signs(dt1), _signs(dt2)):
713 fmt = 'op: %s, dt1: %s, dt2: %s, sg1: %s, sg2: %s'
714 msg = fmt % (op.__name__, dt1, dt2, sg1, sg2)
715 a = np.array(sg1*71, dtype=dt1)
716 b = np.array(sg2*19, dtype=dt2)
717 div, rem = op(a, b)
718 assert_equal(div*b + rem, a, err_msg=msg)
719 if sg2 == -1:
720 assert_(b < rem <= 0, msg)
721 else:
722 assert_(b > rem >= 0, msg)
723
724 def test_float_remainder_exact(self):
725 # test that float results are exact for small integers. This also

Callers

nothing calls this directly

Calls 3

assert_equalFunction · 0.90
assert_Function · 0.90
_signsFunction · 0.70

Tested by

no test coverage detected