Beispiel #1
0
 def test_dissimilarity_fake(self):
     """ Compare dissimalirity values computed by hands """
     city = fake_city()
     d = mb.dissimilarity(city)
     d_answer = {1: {1:0.0, 2:0.5205882352941176, 3:0.411764705882353}, 
                 2: {1:0.5205882352941176, 2:0.0, 3:0.4411764705882353}, 
                 3: {1:0.411764705882353, 2:0.4411764705882353, 3:0.0}}
     for c0 in d:
         for c1 in d[c0]:
             assert_equal(d[c0][c1], d_answer[c0][c1])
Beispiel #2
0
 def test_dissimilarity_segregated_city(self):
     """ 1 in the segregated city """
     city = segregated_city()
     d = mb.dissimilarity(city)
     d_answer = {1:{1:0, 2:1, 3:1},
                2:{1:1, 2:0, 3:1},
                3:{1:1, 2:1, 3:0}}
     for c0 in d:
         for c1 in d[c0]:
             assert_equal(d[c0][c1], d_answer[c0][c1])
Beispiel #3
0
 def test_dissimilarity_uniform_city(self):
     """ Null values in the uniform city """
     city = uniform_city()
     d = mb.dissimilarity(city)
     d_answer = {1:{1:0, 2:0, 3:0},
                2:{1:0, 2:0, 3:0},
                3:{1:0, 2:0, 3:0}}
     for c0 in d:
         for c1 in d[c0]:
             assert_equal(d[c0][c1], d_answer[c0][c1])
Beispiel #4
0
 def test_dissimilarity_uniform_city(self):
     """ Null values in the uniform city """
     city = uniform_city()
     d = mb.dissimilarity(city)
     d_answer = {
         1: {
             1: 0,
             2: 0,
             3: 0
         },
         2: {
             1: 0,
             2: 0,
             3: 0
         },
         3: {
             1: 0,
             2: 0,
             3: 0
         }
     }
     for c0 in d:
         for c1 in d[c0]:
             assert_equal(d[c0][c1], d_answer[c0][c1])
Beispiel #5
0
 def test_dissimilarity_fake(self):
     """ Compare dissimalirity values computed by hands """
     city = fake_city()
     d = mb.dissimilarity(city)
     d_answer = {
         1: {
             1: 0.0,
             2: 0.5205882352941176,
             3: 0.411764705882353
         },
         2: {
             1: 0.5205882352941176,
             2: 0.0,
             3: 0.4411764705882353
         },
         3: {
             1: 0.411764705882353,
             2: 0.4411764705882353,
             3: 0.0
         }
     }
     for c0 in d:
         for c1 in d[c0]:
             assert_equal(d[c0][c1], d_answer[c0][c1])
Beispiel #6
0
 def test_dissimilarity_segregated_city(self):
     """ 1 in the segregated city """
     city = segregated_city()
     d = mb.dissimilarity(city)
     d_answer = {
         1: {
             1: 0,
             2: 1,
             3: 1
         },
         2: {
             1: 1,
             2: 0,
             3: 1
         },
         3: {
             1: 1,
             2: 1,
             3: 0
         }
     }
     for c0 in d:
         for c1 in d[c0]:
             assert_equal(d[c0][c1], d_answer[c0][c1])