| 2573 | ) |
| 2574 | |
| 2575 | def test_divmod(self): |
| 2576 | # A few sizes for the inputs with and without broadcasting |
| 2577 | sizes = [ |
| 2578 | ((1,), (1,)), |
| 2579 | ((1,), (10,)), |
| 2580 | ((10,), (1,)), |
| 2581 | ((3,), (3,)), |
| 2582 | ((2, 2, 2), (1, 2, 1)), |
| 2583 | ((2, 1, 2), (1, 2, 1)), |
| 2584 | ((2, 2, 2, 2), (2, 2, 2, 2)), |
| 2585 | ] |
| 2586 | types = [np.uint16, np.uint32, np.int32, np.float16, np.float32] |
| 2587 | for s1, s2 in sizes: |
| 2588 | for t in types: |
| 2589 | a_np = np.random.uniform(1, 100, size=s1).astype(t) |
| 2590 | b_np = np.random.uniform(1, 100, size=s2).astype(t) |
| 2591 | np_out = np.divmod(a_np, b_np) |
| 2592 | mx_out = mx.divmod(mx.array(a_np), mx.array(b_np)) |
| 2593 | self.assertTrue( |
| 2594 | np.allclose(np_out[0], mx_out[0]), msg=f"Shapes {s1} {s2}, Type {t}" |
| 2595 | ) |
| 2596 | |
| 2597 | def test_tile(self): |
| 2598 | self.assertCmpNumpy([(2,), [2]], mx.tile, np.tile) |