Shape n, expresses the shape of a 1d array with n items, and n, 1 the shape of a n-row x 1-column array. (r,) and (r,1) just add (useless) parentheses but still express respectively 1d and 2d array … The shape attribute for numpy arrays returns the dimensions of the array.

So y. shape[0] is n.