# welcome to softhunt.net
# Python Program illustrating
# numpy.repeat()
import numpy as np
arr = np.arange(6).reshape(2, 3)
print("arr :
", arr)
repetitions = 2
print("
Repeating arr :
", np.repeat(arr, repetitions, 1))
print("arr Shape :
", np.repeat(arr, repetitions).shape)
repetitions = 2
print("
Repeating arr :
", np.repeat(arr, repetitions, 0))
print("arr Shape :
", np.repeat(arr, repetitions).shape)
repetitions = 3
print("
Repeating arr :
", np.repeat(arr, repetitions, 1))
print("arr Shape :
", np.repeat(arr, repetitions).shape)
a = np.array([0, 1, 2])
>>> np.tile(a, 2)
array([0, 1, 2, 0, 1, 2])
>>> np.tile(a, (2, 2))
array([[0, 1, 2, 0, 1, 2],
[0, 1, 2, 0, 1, 2]])
>>> np.tile(a, (2, 1, 2))
array([[[0, 1, 2, 0, 1, 2]],
[[0, 1, 2, 0, 1, 2]]])
# welcome to softhunt.net
# Python Program illustrating
# numpy.repeat()
import numpy as np
#Working on 1D
arr = np.arange(5)
print("arr :
", arr)
repetitions = 2
a = np.repeat(arr, repetitions)
print("
Repeating arr 2 times :
", a)
print("Shape : ", a.shape)
repetitions = 3
a = np.repeat(arr, repetitions)
print("
Repeating arr 3 times :
", a)
# [0 0 0 ..., 4 4 4] means [0 0 0 1 1 1 2 2 2 3 3 3 4 4 4]
# since it was long output, so it uses [ ... ]
print("Shape : ", a.shape)