Пример #1
0
    def initialize(self, start, end, size):
        """ Calculate effective start, end, length and pagesize values
        """
        start, end, sz = opt(start, end, size, self.orphan,
                             self.sequence_length)

        self.pagesize = sz
        self.start = start
        self.end = end

        self.first = max(start - 1, 0)
        if self.beyond:
            self.first = self.end
        self.length = self.end - self.first

        self.last = self.sequence_length - size

        # Set up the total number of pages
        self.numpages = calculate_pagenumber(
            self.sequence_length - self.orphan, self.pagesize, self.overlap)

        # Set up the current page number
        self._pagenumber = calculate_pagenumber(
            self.start, self.pagesize, self.overlap)

        # Make sure self._pagenumber is <= self.numpages
        if self._pagenumber > self.numpages:
            self._pagenumber = self.numpages
Пример #2
0
    def initialize(self, start, end, size):
        """ Calculate effective start, end, length and pagesize values
        """
        start, end, sz = opt(start, end, size, self.orphan,
                             self.sequence_length)

        self.pagesize = sz
        self.start = start
        self.end = end

        self.first = max(start - 1, 0)
        if self.beyond:
            self.first = self.end
        self.length = self.end - self.first

        self.last = self.sequence_length - size

        # Set up the total number of pages
        self.numpages = calculate_pagenumber(
            self.sequence_length - self.orphan, self.pagesize, self.overlap)

        # Set up the current page number
        self._pagenumber = calculate_pagenumber(self.start, self.pagesize,
                                                self.overlap)

        # Make sure self._pagenumber is <= self.numpages
        if self._pagenumber > self.numpages:
            self._pagenumber = self.numpages
Пример #3
0
 def test_opt_end_smaller_start(self):
     # end > start
     self.assertEqual(opt(20, 10, 5, 0, 100), (20, 20, 5))
Пример #4
0
 def test_opt_start_bigger_length(self):
     # start > length
     self.assertEqual(opt(20, 0, 5, 0, 10), (10, 10, 5))
Пример #5
0
 def test_opt_nosize_noend(self):
     # no size and no valid start and end parameters given
     self.assertEqual(opt(1, 0, 0, 0, 100), (1, 25, 25))
Пример #6
0
 def test_opt_nosize_start_end(self):
     # no size given, but valid start and end parameters
     self.assertEqual(opt(1, 31, 0, 0, 100), (1, 31, 31))
Пример #7
0
 def test_opt_overlap(self):
     # overlap
     self.assertEqual(opt(1, 0, 5, 2, 7), (1, 7, 5))
Пример #8
0
 def test_opt_standard(self):
     self.assertEqual(opt(1, 0, 5, 0, 100), (1, 5, 5))
Пример #9
0
 def test_opt_end_smaller_start(self):
     # end > start
     self.assertEqual(opt(20, 10, 5, 0, 100), (20, 20, 5))
Пример #10
0
 def test_opt_start_bigger_length(self):
     # start > length
     self.assertEqual(opt(20, 0, 5, 0, 10), (10, 10, 5))
Пример #11
0
 def test_opt_nosize_noend(self):
     # no size and no valid start and end parameters given
     self.assertEqual(opt(1, 0, 0, 0, 100), (1, 25, 25))
Пример #12
0
 def test_opt_nosize_start_end(self):
     # no size given, but valid start and end parameters
     self.assertEqual(opt(1, 31, 0, 0, 100), (1, 31, 31))
Пример #13
0
 def test_opt_overlap(self):
     # overlap
     self.assertEqual(opt(1, 0, 5, 2, 7), (1, 7, 5))
Пример #14
0
 def test_opt_standard(self):
     self.assertEqual(opt(1, 0, 5, 0, 100), (1, 5, 5))