Example #1
0
 def test_group_matches(self):
     row_matches = [
         [0,1,2,3],
         [0,1],
         [1,3]
     ]
     grouped = transform.group_matches(row_matches)
     expected = [1]
     self.assertSequenceEqual(tuple(grouped), tuple(expected))
Example #2
0
 def test_group_matches_2(self):
     row_matches = [
         [0,1,2,3,4],
         [2],
         [1,2,3],
         [0,2,4]
     ]
     grouped = transform.group_matches(row_matches)
     expected = [2]
     self.assertListEqual(grouped, expected)
Example #3
0
    def test_same_height(self):
        test_pattern = [
            [1],
            [2],
            [2],
            [1]
        ]

        ship = [
            [1, 1, 2, 1, 1],
            [1, 2, 2, 2, 1],
            [1, 2, 1, 2, 1],
            [1, 1, 1, 1, 1]
        ]

        result = transform.group_matches(transform.match_matrix_same_height(test_pattern, ship))
        self.assertListEqual(result, [1,3])
Example #4
0
    def test_same_height_grouped(self):
        test_pattern = [
            [1],
            [2],
            [2],
            [1]
        ]

        ship = [
            [1, 1, 1, 1, 1],
            [1, 1, 2, 1, 1],
            [1, 2, 2, 2, 1],
            [1, 2, 1, 2, 1]
        ]

        ungrouped = transform.match_matrix_same_height(test_pattern, ship)
        grouped = transform.group_matches(ungrouped)

        self.assertListEqual(grouped, [2])