#NEWLINE# def test_compare_tip_distances( self ) : #NEWLINE# #INDENT# t = TreeNode . read ( io . StringIO ( '((H:1,G:1):2,(R:0.5,M:0.7):3);' ) ) #NEWLINE# t2 = TreeNode . read ( io . StringIO ( '(((H:1,G:1,O:1):2,R:3):1,X:4);' ) ) #NEWLINE# obs = t . compare_tip_distances ( t2 ) #NEWLINE# m1 = np . array ( [ [ 0 , 2 , 6.5 ] , [ 2 , 0 , 6.5 ] , [ 6.5 , 6.5 , 0 ] ] ) #NEWLINE# m2 = np . array ( [ [ 0 , 2 , 6 ] , [ 2 , 0 , 6 ] , [ 6 , 6 , 0 ] ] ) #NEWLINE# r = pearsonr ( m1 . flat , m2 . flat ) [ 0 ] #NEWLINE# self . assertAlmostEqual ( obs , ( ( 1 - obs ) / 2 ) )