(self)
| 2460 | self.assertEqual(out_t, mx.float32) |
| 2461 | |
| 2462 | def test_linspace(self): |
| 2463 | # Test default num = 50 |
| 2464 | a = mx.linspace(0, 1) |
| 2465 | expected = mx.array(np.linspace(0, 1)) |
| 2466 | self.assertEqualArray(a, expected) |
| 2467 | |
| 2468 | # Test int64 dtype |
| 2469 | b = mx.linspace(0, 10, 5, mx.int64) |
| 2470 | expected = mx.array(np.linspace(0, 10, 5, dtype=int)) |
| 2471 | self.assertEqualArray(b, expected) |
| 2472 | |
| 2473 | # Test negative sequence with float start and stop |
| 2474 | c = mx.linspace(-2.7, -0.7, 7) |
| 2475 | expected = mx.array(np.linspace(-2.7, -0.7, 7)) |
| 2476 | self.assertEqualArray(c, expected) |
| 2477 | |
| 2478 | # Test irrational step size of 1/9 |
| 2479 | d = mx.linspace(0, 1, 10) |
| 2480 | expected = mx.array(np.linspace(0, 1, 10)) |
| 2481 | self.assertEqualArray(d, expected) |
| 2482 | |
| 2483 | # Test num equal to 1 |
| 2484 | d = mx.linspace(1, 10, 1) |
| 2485 | expected = mx.array(np.linspace(1, 10, 1)) |
| 2486 | self.assertEqualArray(d, expected) |
| 2487 | |
| 2488 | # Ensure that the start and stop are always the ones provided |
| 2489 | ranges = mx.random.normal((16, 2)).tolist() |
| 2490 | nums = (2 + mx.random.uniform(shape=(16,)) * 10).astype(mx.uint32).tolist() |
| 2491 | for (a, b), n in zip(ranges, nums): |
| 2492 | d = mx.linspace(a, b, n).tolist() |
| 2493 | self.assertEqual(d[0], a) |
| 2494 | self.assertEqual(d[-1], b) |
| 2495 | |
| 2496 | def test_repeat(self): |
| 2497 | # Setup data for the tests |
nothing calls this directly
no test coverage detected