| 909 | |
| 910 | @derived_from(np) |
| 911 | def tile(A, reps): |
| 912 | try: |
| 913 | tup = tuple(reps) |
| 914 | except TypeError: |
| 915 | tup = (reps,) |
| 916 | if any(i < 0 for i in tup): |
| 917 | raise ValueError("Negative `reps` are not allowed.") |
| 918 | c = asarray(A) |
| 919 | |
| 920 | if all(tup): |
| 921 | for nrep in tup[::-1]: |
| 922 | c = nrep * [c] |
| 923 | return block(c) |
| 924 | |
| 925 | d = len(tup) |
| 926 | if d < c.ndim: |
| 927 | tup = (1,) * (c.ndim - d) + tup |
| 928 | if c.ndim < d: |
| 929 | shape = (1,) * (d - c.ndim) + c.shape |
| 930 | else: |
| 931 | shape = c.shape |
| 932 | shape_out = tuple(s * t for s, t in zip(shape, tup)) |
| 933 | return empty(shape=shape_out, dtype=c.dtype) |
| 934 | |
| 935 | |
| 936 | def expand_pad_value(array, pad_value): |