def test_correlation(self): # data: 20 samples, 80 features X = np.random.rand(20, 80) C = 1 - one_minus_correlation(X, X) # get nsample x nssample correlation matrix self.assertTrue(C.shape == (20, 20)) # diagonal is 1 self.assertTrue((np.abs(np.diag(C) - 1).mean() < 0.00001).all()) # now two different Y = np.random.rand(5, 80) C2 = 1 - one_minus_correlation(X, Y) # get nsample x nssample correlation matrix self.assertTrue(C2.shape == (20, 5)) # external validity check -- we are dealing with correlations self.assertTrue(C2[10, 2] - np.corrcoef(X[10], Y[2])[0, 1] < 0.000001)