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

Method test_modulus_basic

numpy/core/tests/test_scalarmath.py:295–309  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

293class TestModulus:
294
295 def test_modulus_basic(self):
296 dt = np.typecodes['AllInteger'] + np.typecodes['Float']
297 for op in [floordiv_and_mod, divmod]:
298 for dt1, dt2 in itertools.product(dt, dt):
299 for sg1, sg2 in itertools.product(_signs(dt1), _signs(dt2)):
300 fmt = 'op: %s, dt1: %s, dt2: %s, sg1: %s, sg2: %s'
301 msg = fmt % (op.__name__, dt1, dt2, sg1, sg2)
302 a = np.array(sg1*71, dtype=dt1)[()]
303 b = np.array(sg2*19, dtype=dt2)[()]
304 div, rem = op(a, b)
305 assert_equal(div*b + rem, a, err_msg=msg)
306 if sg2 == -1:
307 assert_(b < rem <= 0, msg)
308 else:
309 assert_(b > rem >= 0, msg)
310
311 def test_float_modulus_exact(self):
312 # 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