예제 #1
0
    def test_same_height_2(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]
        ]

        expected = [
            [0,1,2,3,4],
            [2],
            [1,2,3],
            [0,2,4]
        ]

        result = transform.match_matrix_same_height(test_pattern, ship)

        # test generator of generators
        for index, row in enumerate(result):
            self.assertSequenceEqual(tuple(row), tuple(expected[index]))
예제 #2
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])
예제 #3
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])