| 716 | |
| 717 | |
| 718 | def test_repeat(): |
| 719 | x = np.random.random((10, 11, 13)) |
| 720 | d = da.from_array(x, chunks=(4, 5, 3)) |
| 721 | |
| 722 | repeats = [0, 1, 2, 5] |
| 723 | axes = [-3, -2, -1, 0, 1, 2] |
| 724 | |
| 725 | for r in repeats: |
| 726 | for a in axes: |
| 727 | assert_eq(x.repeat(r, axis=a), d.repeat(r, axis=a)) |
| 728 | |
| 729 | assert_eq(d.repeat(2, 0), da.repeat(d, 2, 0)) |
| 730 | |
| 731 | with pytest.raises(NotImplementedError): |
| 732 | da.repeat(d, np.arange(10)) |
| 733 | |
| 734 | with pytest.raises(NotImplementedError): |
| 735 | da.repeat(d, 2, None) |
| 736 | |
| 737 | with pytest.raises(NotImplementedError): |
| 738 | da.repeat(d, 2) |
| 739 | |
| 740 | for invalid_axis in [3, -4]: |
| 741 | with pytest.raises(ValueError): |
| 742 | da.repeat(d, 2, axis=invalid_axis) |
| 743 | |
| 744 | x = np.arange(5) |
| 745 | d = da.arange(5, chunks=(2,)) |
| 746 | |
| 747 | assert_eq(x.repeat(3), d.repeat(3)) |
| 748 | |
| 749 | for r in [1, 2, 3, 4]: |
| 750 | assert all(concat(d.repeat(r).chunks)) |
| 751 | |
| 752 | |
| 753 | @pytest.mark.parametrize("reps", [2, (2, 2), (1, 2), (2, 1), (2, 3, 4, 0)]) |