I am trying to form a 3D array in Python by populating it with 2D arrays. N is a number than varies depending on the file being read. The matrix is forming as 3D but only appears to have 1 'layer' to it when I am expecting it to have N layers. It appears that the N number of 'layers' is not being passed into the formed array.
import numpy as np
#'rot' is a 3D matrix of shape (N,3,3)
a=np.array(rot[:,0,0])
b=np.array(rot[:,0,1])
c=np.array(rot[:,0,2])
d=np.array(rot[:,1,0])
e=np.array(rot[:,1,1])
f=np.array(rot[:,1,2])
g=np.array(rot[:,2,0])
h=np.array(rot[:,2,1])
i=np.array(rot[:,2,2])
print(a.shape)
#(N,)
#Forming 3D array
arr=np.array([[[a,b,1],
[d,e,1],
[g,h,i]]])
print(arr.shape)
#(1,3,3)
1entries are likely causing a problem since the array now has vectors of lengthNand integers. Trynp.array([1]*N)to get a vector of 1s with the same shape as the other elements.arr? Orarr.dtype. Don't just look atshape, especially when the shape is unexpected.[].