Consider the following:
A = np.zeros((2,3))
print(A)
[[ 0. 0. 0.]
[ 0. 0. 0.]]
This make sense to me. I'm telling numpy to make a 2x3 matrix, and that's what I get.
However, the following:
B = np.zeros((2, 3, 4))
print(B)
Gives me this:
[[[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]]
[[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]
[ 0. 0. 0. 0.]]]
This doesn't make sense to me. Aren't I telling numpy to make a cube which has 4 2x3 matrices? I'm even more confused because although the data structure looks incorrect, the slicing works exactly as planned:
print(B[:,:,1])
[[ 0. 0. 0.]
[ 0. 0. 0.]]
I'm missing something about how these arrays are constructed, but I'm not sure what. Can someone explain what I'm missing or not understanding?
Thanks so much!