In [17]:
import numpy as np
# we have an array a and we wanna repeat it 5 times on the 3th dimention
a = np.ones((20, 10))

# Broadcast: broadcast an array to a new shape
bc = np.broadcast_to(a.reshape(20, 10, 1), (20, 10, 5)) # repeat 5 times

# Repeat: repeat elements of an array
rp = a.reshape(20, 10, 1).repeat(5, axis=2)  
#>>> x = np.array([[1,2],[3,4]])
#>>> np.repeat(x, 2)
#array([1, 1, 2, 2, 3, 3, 4, 4])

# Tile: construct array by repeating A the number of times given by reps
tl = np.tile(a.reshape(20, 10, 1), (1, 1, 5))

a.reshape(20, 10, 1)
# which is equalant to
# a[:, :, np.newaxis]
# and
# np.expand_dims(a, axis=2)


Out[17]:
(20, 10, 5)

In [33]:
import numpy as np
x=np.arange(5).reshape(1, 5).repeat(4, axis=0)

rows = np.array([0,3])
columns = np.array([0, 4])

x[np.ix_(rows, columns)]
x[...]
# y = x[1:8:2, : : -1]
# obj = (slice(1, 8, 2), slice(None, None, -1)) 
# z = x[obj]


Out[33]:
array([[0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4],
       [0, 1, 2, 3, 4]])

In [ ]:
file = open('test.txt', 'w')
a = [1, 2., (2, 3, 4)]

In [ ]:
import numpy as np
a = np.ones((10, 10, 10))