Update:
To address what I am guessing is your actual question (see my comment above).
Assuming your board is an array with the shape (X, Y, ...). If you want split that up into 25 tiles shaped (X/5, Y/5, ...), you can simply do the following:
- Split it into 5 "vertical" tiles once along axis 1 (horizontally or column-wise) giving you an array with the shape
(5, X, Y/5, ...), i.e. with each tile having the shape (X, Y/5, ...).
- Split that array into 5 again along axis 1, which effectively means splitting each of the 5 tiles along their respective axis 0 (vertically or row-wise). Each of those tiles we got from step 1 will then have the shape
(5, X/5, Y/5, ...), meaning each sub-tile will be split into 5 tiles of shape (X/5, Y/5, ...).
Say we have array a with the shape (10, 15):
a = np.arange(150).reshape(10, 15)
print(a)
[[ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
[ 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29]
[ 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44]
[ 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59]
[ 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74]
[ 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89]
[ 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104]
[105 106 107 108 109 110 111 112 113 114 115 116 117 118 119]
[120 121 122 123 124 125 126 127 128 129 130 131 132 133 134]
[135 136 137 138 139 140 141 142 143 144 145 146 147 148 149]]
Step 1, using numpy.hsplit, which is equivalent to numpy.split with axis=1:
a1 = np.array(np.hsplit(a, 5))
print(a1)
[[[ 0 1 2]
[ 15 16 17]
...
[120 121 122]
[135 136 137]]
[[ 3 4 5]
[ 18 19 20]
...
[123 124 125]
[138 139 140]]
[[ 6 7 8]
[ 21 22 23]
...
[126 127 128]
[141 142 143]]
[[ 9 10 11]
[ 24 25 26]
...
[129 130 131]
[144 145 146]]
[[ 12 13 14]
[ 27 28 29]
...
[132 133 134]
[147 148 149]]]
Step 2:
a2 = np.array(np.hsplit(a1, 5))
print(a2)
[[[[ 0 1 2]
[ 15 16 17]]
...
[[ 12 13 14]
[ 27 28 29]]]
[[[ 30 31 32]
[ 45 46 47]]
...
[[ 42 43 44]
[ 57 58 59]]]
...
...
...
[[[120 121 122]
[135 136 137]]
...
[[132 133 134]
[147 148 149]]]]
Thus you can achieve the final result in one line like so:
b = np.array(np.hsplit(np.array(np.hsplit(a, 5)), 5))
print(b.shape)
(5, 5, 2, 3)
Then you have 5 x 5 tiles with the shape (2, 3).
Thus, you should be able to achieve what you want, by doing this:
slices = np.array(np.hsplit(np.array(np.hsplit(board, 5)), 5))
Avoid for-loops as much as possible, if you are already working with numpy arrays. Almost always there is a numpy-solution that is orders of magnitude faster (and probably more concise at that).
Hope this helps.
Original answer:
Given an array a with the shape (25, X, Y, Z, ...) you can simply reshape it to (5, 5, X, Y, Z, ...) like this:
a.reshape((5, 5) + a.shape[1:])
For example given a = np.arange(25*2).reshape((25, 2)), the array looks like this:
array([[ 0, 1],
[ 2, 3],
...
[46, 47],
[48, 49]])
And after the reshaping it looks like this:
array([[[ 0, 1],
[ 2, 3],
[ 4, 5],
[ 6, 7],
[ 8, 9]],
...
[[40, 41],
[42, 43],
[44, 45],
[46, 47],
[48, 49]]])
slicekeyword as variable name.board.shape?boardwith the shape(X, Y, ...)to be divided up into 25 tiles, where each tile has the shape(X/5, Y/5, ...)and you want those tiles to end up in a array with the shape(5, 5, X/5, Y/5, ...). Do I understand you correctly?