def test_randomize_corrmat():
 a = rs.randn(30)
 b = (a + (rs.rand(30) * 3))
 c = rs.randn(30)
 d = [a, b, c]
 (p_mat, dist) = algo.randomize_corrmat(d, tail='upper', corrected=False, return_dist=True)
 nose.tools.assert_greater(p_mat[(2, 0)], p_mat[(1, 0)])
 corrmat = np.corrcoef(d)
 pctile = (100 - stats.percentileofscore(dist[(2, 1)], corrmat[(2, 1)]))
 nose.tools.assert_almost_equal((p_mat[(2, 1)] * 100), pctile)
 d[1] = ((- a) + rs.rand(30))
 p_mat = algo.randomize_corrmat(d)
 nose.tools.assert_greater(0.05, p_mat[(1, 0)])

def test_randomize_corrmat ( ) : a = rs . randn ( 30 ) b = ( a + ( rs . rand ( 30 ) * 3 ) ) c = rs . randn ( 30 ) d = [ a , b , c ] ( p_mat , dist ) = algo . randomize_corrmat ( d , tail = 'upper' , corrected = False , return_dist = True ) nose . tools . assert_greater ( p_mat [ ( 2 , 0 ) ] , p_mat [ ( 1 , 0 ) ] ) corrmat = np . corrcoef ( d ) pctile = ( 100 - stats . percentileofscore ( dist [ ( 2 , 1 ) ] , corrmat [ ( 2 , 1 ) ] ) ) nose . tools . assert_almost_equal ( ( p_mat [ ( 2 , 1 ) ] * 100 ) , pctile ) d [ 1 ] = ( ( - a ) + rs . rand ( 30 ) ) p_mat = algo . randomize_corrmat ( d ) nose . tools . assert_greater ( 0.05 , p_mat [ ( 1 , 0 ) ] )
test the correctness of the correlation matrix p values .