I am obtaining several values of two matrices L and R of expected dimensions of 2200x88 for each ith iteration of a for loop using Numpy (Python). some of the matrices have fewer elements for example 1200x55, in those cases I have to add zeros to the matrix to reshape it to be of 2200x88 dimension. I have created the following program to solve that problem:
for line in infile:
line = line.strip()
#more code here, l is matrix 1 of the ith iteration, r is matrix 2 of ith iteration
ls1, ls2=l.shape
rs1, rs2= r.shape
if ls1 != 2200 | ls2 != 88:
l.resize((2200, 88), refcheck=False)
if rs1 != 2200 | rs2 != 88:
r.resize((2200, 88), refcheck=False)
var = np.concatenate((l, r), axis=0).reshape(1,387200)
The problem is that when a matrix R or L is detected not to be of dimensions 2200 by 88 I obtain the following error:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
Has anyone any recommendations on how to solve this?
Thank you.