You can calculate the correlation matrix and ask if only the diagonal elements are 1:
(np.corrcoef(M)==1).sum()==M.shape[0] In [66]: M = np.random.random((5,8)) In [72]: (np.corrcoef(M)==1).sum()==M.shape[0] Out[72]: True
This if you want to do a similar thing for the columns:
(np.corrcoef(M, rowvar=0)==1).sum()==M.shape[1]
or without numpy at all:
len(set(map(tuple,M)))==len(M)
Fiter out the unique rows and then test if the resultant is same as M is an overkill:
In [99]: %%timeit b = np.ascontiguousarray(M).view(np.dtype((np.void, M.dtype.itemsize * M.shape[1]))) _, idx = np.unique(b, return_index=True) unique_M = M[idx] unique_M.shape==M.shape 10000 loops, best of 3: 54.6 µs per loop In [100]: %timeit len(set(map(tuple,M)))==len(M) 10000 loops, best of 3: 24.9 µs per loop