0
votes

I have written this piece of code:

w = Dist.argsort(kind='mergesort');
return y[w];

where w is MxN matrix, and y is Nx1 vector. Everything works fine if shape returned by np.shape(y) is (3,). However, when I try to input a vector of shape(3,1), my function returns a 3-dimensional MXNx1 matrix.

Is there a way to reduce (N,1) vector to (N,) size? Or to normalize output of the function for (N,1) vectors?

1

1 Answers

0
votes

You can reduce an (N,1) numpy array to (N,) with flatten:

>>>np.zeros((3, 1)).shape
(3, 1)

>>>np.zeros((3, 1)).flatten().shape
(3,)