Exemplo n.º 1
0
def match(costs):

    start = time()
    m = munkres.Munkres()
    match = m.compute(costs.copy())
    print("Munkres: %fs"%(time()-start))
    print(match)

    start = time()
    match = pymatch.match(costs.copy())
    print("pymatch: %fs"%(time()-start))
    print(match)
Exemplo n.º 2
0
 def test_match_no_tuple_types(self):
     result = match([((bool, bool, bool), lambda i: True)], (4, 5, 6))
     assert result is None
Exemplo n.º 3
0
 def test_match_partial_tuple_types(self):
     result = match([((int, int, bool), lambda i, j, k: True)], (1, 2, 4))
     assert result is None
Exemplo n.º 4
0
 def test_match_tuple_types(self):
     result = match([((int, int, int), lambda i, j, k: True)], (1, 2, 3))
     assert result
Exemplo n.º 5
0
 def test_no_patterns(self):
     result = match([], "Hello World")
     assert result is None
Exemplo n.º 6
0
 def test_match_no_tuple_values(self):
     result = match([((1, 2, 3), lambda i: True)], (4, 5, 6))
     assert result is None
Exemplo n.º 7
0
 def test_does_not_match(self):
     result = match([(int, lambda i: i + 1)], "Hello World")
     assert result is None
Exemplo n.º 8
0
 def test_first_match(self):
     result = match([(int, lambda i: True), (any, lambda i: False)],
                    "hello")
     assert not result
Exemplo n.º 9
0
 def test_match_regex(self):
     result = match([(Regex("^abc[a-z]*"), lambda i: True)], "abcdefg")
     assert result
Exemplo n.º 10
0
 def test_match_basic_bool(self):
     match = pattern((bool, lambda i: False))
     result = match(True)
     assert not result
Exemplo n.º 11
0
 def test_match_basic_float(self):
     match = pattern((float, lambda i: i + 1))
     result = match(0.0)
     assert result == 1.0
Exemplo n.º 12
0
 def test_match_basic_int(self):
     match = pattern((int, lambda i: i + 1))
     result = match(0)
     assert result == 1
Exemplo n.º 13
0
 def test_match_basic_str(self):
     match = pattern((str, lambda i: "goodbye"))
     result = match("Hello World")
     assert result == "goodbye"
Exemplo n.º 14
0
 def test_does_not_match_pattern(self):
     match = pattern((int, lambda i: i + 1))
     result = match("Hello World")
     assert result is None
Exemplo n.º 15
0
 def test_match_partial_tuple_types_etc(self):
     result = match([((int, int, etc), lambda i, j, k, l, m: True)],
                    (1, 2, 6, 7, 8))
     assert result
Exemplo n.º 16
0
 def test_first_match(self):
     result = match([(int, lambda i: True), (int, lambda i: False)], 1)
     assert result
Exemplo n.º 17
0
 def test_match_tuple_values(self):
     result = match([((1, 2, 3), lambda i, j, k: True)], (1, 2, 3))
     assert result
Exemplo n.º 18
0
 def test_match_partial_tuple_values(self):
     result = match([((1, 2, 3), lambda i, j, k: True)], (1, 2, 4))
     assert result is None
Exemplo n.º 19
0
 def test_no_patterns_pattern(self):
     match = pattern()
     result = match("Hello World")
     assert result is None