#NEWLINE# def test_sorensen_distances( ) : #NEWLINE# #INDENT# ' Check that the pairwise Sorensen distances computation' #NEWLINE# X = [ [ 'a' , 'b' , 'c' ] ] #NEWLINE# D = sorensen_coefficient ( X , X ) #NEWLINE# assert_array_almost_equal ( D , [ [ 1.0 ] ] ) #NEWLINE# X = [ [ 'a' , 'b' , 'c' ] ] #NEWLINE# Y = [ [ ] ] #NEWLINE# D = sorensen_coefficient ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.0 ] ] ) #NEWLINE# X = [ [ 1 , 2 , 3 , 4 ] ] #NEWLINE# Y = [ [ 2 , 3 ] ] #NEWLINE# D = sorensen_coefficient ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.666666 ] ] ) #NEWLINE# X = [ [ 'a' , 'b' , 'c' , 'd' ] , [ 'e' , 'f' , 'g' ] ] #NEWLINE# Y = [ [ 'a' , 'b' , 'c' , 'k' ] ] #NEWLINE# D = sorensen_coefficient ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.75 ] , [ 0.0 ] ] ) #NEWLINE# X = [ [ 'a' , 'b' , 'c' , 'd' ] , [ 'e' , 'f' , 'g' ] ] #NEWLINE# Y = [ [ 'a' , 'b' , 'c' , 'd' ] , [ 'e' , 'f' , 'g' ] ] #NEWLINE# D = sorensen_coefficient ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 1.0 , 0.0 ] , [ 0.0 , 1.0 ] ] ) #NEWLINE# X = [ [ 0 , 1 ] , [ 1 , 2 ] ] #NEWLINE# D = sorensen_coefficient ( X , X ) #NEWLINE# assert_array_almost_equal ( D , [ [ 1.0 , 0.5 ] , [ 0.5 , 1.0 ] ] ) #NEWLINE# X = [ [ 0 , 1 ] , [ 1 , 2 ] ] #NEWLINE# Y = [ [ 0 , 0 ] ] #NEWLINE# D = sorensen_coefficient ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.5 ] , [ 0.0 ] ] )