Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(2)  |  Call(2)  |  Derive(0)  |  Import(0)
Get all the bin numbers for a particular interval defined by
(start, end]

            @staticmethod
    def bins(start, end):
        """
        Get all the bin numbers for a particular interval defined by
        (start, end]
        """
        if end - start < 536870912:
            offsets = [585, 73, 9, 1]
        else:
            raise BigException
            offsets = [4681, 585, 73, 9, 1]
        binFirstShift = 17
        binNextShift = 3

        start = start >> binFirstShift
        end = (end - 1)  >> binFirstShift

        bins = [1]
        for offset in offsets:
            bins.extend(range(offset + start, offset + end + 1))
            start >>= binNextShift
            end >>= binNextShift
        return frozenset(bins)
        


src/c/r/cruzdb-HEAD/cruzdb/tests/test_db.py   cruzdb(Download)
    def test_bins(self):
        bins = Genome.bins(12345, 56779)
        expected = set([1, 9, 73, 585])
        self.assertEqual(bins, expected)
 

src/c/r/cruzdb-0.5.4/cruzdb/tests/test_db.py   cruzdb(Download)
    def test_bins(self):
        bins = Genome.bins(12345, 56779)
        expected = set([1, 9, 73, 585])
        self.assertEqual(bins, expected)