(self)
| 293 | class 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 |
nothing calls this directly
no test coverage detected