#NEWLINE# def test_manthattan_distances( ) : #NEWLINE# #INDENT# ' Check that the pairwise Manhattan distances computation' #NEWLINE# X = [ [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] ] #NEWLINE# D = manhattan_distances ( X , X ) #NEWLINE# assert_array_almost_equal ( D , [ [ 1.0 ] ] ) #NEWLINE# X = [ [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] ] #NEWLINE# Y = [ [ ] ] #NEWLINE# assert_raises ( ValueError , manhattan_distances , X , Y ) #NEWLINE# X = [ [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] ] #NEWLINE# Y = [ [ 3.0 , 3.5 , 1.5 , 5.0 , 3.5 , 3.0 ] ] #NEWLINE# D = manhattan_distances ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.25 ] ] ) #NEWLINE# X = [ [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] , [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] ] #NEWLINE# Y = [ [ 3.0 , 3.5 , 1.5 , 5.0 , 3.5 , 3.0 ] ] #NEWLINE# D = manhattan_distances ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.25 ] , [ 0.25 ] ] ) #NEWLINE# X = [ [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] , [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] ] #NEWLINE# Y = [ [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] , [ 2.5 , 3.5 , 3.0 , 3.5 , 2.5 , 3.0 ] ] #NEWLINE# D = manhattan_distances ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 1.0 , 1.0 ] , [ 1.0 , 1.0 ] ] ) #NEWLINE# X = [ [ 0 , 1 ] , [ 1 , 1 ] ] #NEWLINE# D = manhattan_distances ( X , X ) #NEWLINE# assert_array_almost_equal ( D , [ [ 1.0 , 0.5 ] , [ 0.5 , 1.0 ] ] ) #NEWLINE# X = [ [ 0 , 1 ] , [ 1 , 1 ] ] #NEWLINE# Y = [ [ 0 , 0 ] ] #NEWLINE# D = manhattan_distances ( X , Y ) #NEWLINE# assert_array_almost_equal ( D , [ [ 0.5 ] , [ 0.0 ] ] )