Exemple #1
0
def test_scan_dot_in_line(self):
    """Okay! a single line. Find the ink."""

    img = grid(#01234567890123456
               '..#....##.....###')

    found = list( scrape.glyphs_from_line(img, img.ink_p) )
    
    self.assertEquals( 3, len(found))

    the_x,  \
    the_xx, \
    the_xxx = found

    self.assertEqual(1, the_x.width)
    self.assertEqual(2, the_xx.width)
    self.assertEqual(3, the_xxx.width)
    
    self.assertEqual((2, 0), the_x.pos)
    self.assertEqual((1, 1), the_x.size)

    self.assertEqual((7, 0), the_xx.pos)
    self.assertEqual((2, 1), the_xx.size)
    
    self.assertEqual((14, 0), the_xxx.pos)
    self.assertEqual((3, 1), the_xxx.size)
Exemple #2
0
    def test_full_grid(self):

        # the word For from a scan of Mentally Incontinent
        img = StringImage(
            """
            ....................................
            ....................................
            ....................................
            .......#######......................
            ......########......................
            ......###...........................
            ......###.......#####...######......
            ......######...##..###..#####.......
            ......#######.##....##..##..........
            ......###.....##....###.##..........
            ......###.....##....###.##..........
            ......###.....##....##..##..........
            ......###.....###...##..##..........
            ......###......#######..##..........
            .......#........#####...#...........
            ....................................
            ....................................""")
        #  0|     6|             17|1|   6|     6|

        # the old-style glints:
        fo = 11656954525901520401809650090941306687965691406109462313538109468335093405284899504112
        r = 2475936747400903850442391488

        found = list(scrape.glyphs_from_line(img, img.ink_p))
        the_fo, the_r = found
        self.assertEqual((17, fo), the_fo)  # 1 char, 1 in binary
        self.assertEqual((6,   r), the_r)

        self.assertEqual(img.size[1], the_fo.size[1])  # heights should match!
Exemple #3
0
def test_tokenize(self):
    
    img = grid(#01234567890123456
               '.#.#.#..#.#.#')

    found = list( scrape.glyphs_from_line(img, img.ink_p))

    assert len(found) == 6    

    spaced = list(scrape.spaced(found, space_width=2))
    self.assertEquals(len(spaced), 7)
    self.assertEquals(spaced[3], SPACE)
Exemple #4
0
    def test_tokenize(self):

        #                  01234567890123456
        img = StringImage('.#.#.#..#.#.#')

        found = list(scrape.glyphs_from_line(img, img.ink_p))

        assert len(found) == 6

        spaced = list(scrape.spaced(found, space_width=2))
        self.assertEqual(len(spaced), 7)
        self.assertEqual(spaced[3], SPACE)
Exemple #5
0
def test_full_grid(self):

    # the word For from a scan of Mentally Incontinent
    img = grid(
        """
        ....................................
        ....................................
        ....................................
        .......#######......................
        ......########......................
        ......###...........................
        ......###.......#####...######......
        ......######...##..###..#####.......
        ......#######.##....##..##..........
        ......###.....##....###.##..........
        ......###.....##....###.##..........
        ......###.....##....##..##..........
        ......###.....###...##..##..........
        ......###......#######..##..........
        .......#........#####...#...........
        ....................................
        ....................................""")
    #  0|     6|             17|1|   6|     6|

    

    # the old-style glints:
    fo = 11656954525901520401809650090941306687965691406109462313538109468335093405284899504112
    r  = 2475936747400903850442391488
    
    found = list(scrape.glyphs_from_line(img, img.ink_p))
    the_fo, the_r = found
    self.assertEquals((17, fo), the_fo) # 1 char, 1 in binary
    self.assertEquals((6,   r), the_r)

    self.assertEquals(img.size[1], the_fo.size[1]) # heights should match!
Exemple #6
0
    def test_scan_dot_in_line(self):
        """Okay! a single line. Find the ink."""

        #                  01234567890123456
        img = StringImage('..#....##.....###')

        found = list(scrape.glyphs_from_line(img, img.ink_p))

        self.assertEqual(3, len(found))

        the_x, the_xx, the_xxx = found

        self.assertEqual(1, the_x.width)
        self.assertEqual(2, the_xx.width)
        self.assertEqual(3, the_xxx.width)

        self.assertEqual((2, 0), the_x.pos)
        self.assertEqual((1, 1), the_x.size)

        self.assertEqual((7, 0), the_xx.pos)
        self.assertEqual((2, 1), the_xx.size)

        self.assertEqual((14, 0), the_xxx.pos)
        self.assertEqual((3, 1), the_xxx.size)