MCPcopy
hub / github.com/numpy/numpy / tile

Function tile

numpy/lib/_shape_base_impl.py:1158–1247  ·  view source on GitHub ↗

Construct an array by repeating A the number of times given by reps. If `reps` has length ``d``, the result will have dimension of ``max(d, A.ndim)``. If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new axes. So a shape (3,) array is promoted to (1, 3) for

(A, reps)

Source from the content-addressed store, hash-verified

1156
1157@array_function_dispatch(_tile_dispatcher)
1158def tile(A, reps):
1159 """
1160 Construct an array by repeating A the number of times given by reps.
1161
1162 If `reps` has length ``d``, the result will have dimension of
1163 ``max(d, A.ndim)``.
1164
1165 If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new
1166 axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication,
1167 or shape (1, 1, 3) for 3-D replication. If this is not the desired
1168 behavior, promote `A` to d-dimensions manually before calling this
1169 function.
1170
1171 If ``A.ndim > d``, `reps` is promoted to `A`.ndim by prepending 1&#x27;s to it.
1172 Thus for an `A` of shape (2, 3, 4, 5), a `reps` of (2, 2) is treated as
1173 (1, 1, 2, 2).
1174
1175 Note : Although tile may be used for broadcasting, it is strongly
1176 recommended to use numpy&#x27;s broadcasting operations and functions.
1177
1178 Parameters
1179 ----------
1180 A : array_like
1181 The input array.
1182 reps : array_like
1183 The number of repetitions of `A` along each axis.
1184
1185 Returns
1186 -------
1187 c : ndarray
1188 The tiled output array.
1189
1190 See Also
1191 --------
1192 repeat : Repeat elements of an array.
1193 broadcast_to : Broadcast an array to a new shape
1194
1195 Examples
1196 --------
1197 >>> import numpy as np
1198 >>> a = np.array([0, 1, 2])
1199 >>> np.tile(a, 2)
1200 array([0, 1, 2, 0, 1, 2])
1201 >>> np.tile(a, (2, 2))
1202 array([[0, 1, 2, 0, 1, 2],
1203 [0, 1, 2, 0, 1, 2]])
1204 >>> np.tile(a, (2, 1, 2))
1205 array([[[0, 1, 2, 0, 1, 2]],
1206 [[0, 1, 2, 0, 1, 2]]])
1207
1208 >>> b = np.array([[1, 2], [3, 4]])
1209 >>> np.tile(b, 2)
1210 array([[1, 2, 1, 2],
1211 [3, 4, 3, 4]])
1212 >>> np.tile(b, (2, 1))
1213 array([[1, 2],
1214 [3, 4],
1215 [1, 2],

Callers 4

test_basicMethod · 0.90
test_emptyMethod · 0.90
test_kroncompareMethod · 0.90

Calls 2

allFunction · 0.85
reshapeMethod · 0.80

Tested by 4

test_basicMethod · 0.72
test_emptyMethod · 0.72
test_kroncompareMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…