Пример #1
0
    def testDegenerateContainer(self):
        """ Tests that an r-tree still works like a container even with highly overlapping rects. """
        xs = [ TstO(r) for r in take(1000,G.rect, 20.0) ]
        tree = RTree()
        for x in xs: 
            tree.insert(x,x.rect)
            self.invariants(tree)

        ws = [ x.leaf_obj() for x in tree.walk(lambda x,y: True) if x.is_leaf() ]
        for x in xs: self.assertTrue(x in ws)
Пример #2
0
    def testDegenerateContainer(self):
        """ Tests that an r-tree still works like a container even with highly overlapping rects. """
        xs = [TstO(r) for r in take(1000, G.rect, 20.0)]
        tree = RTree()
        for x in xs:
            tree.insert(x, x.rect)
            self.invariants(tree)

        ws = [
            x.leaf_obj() for x in tree.walk(lambda x, y: True) if x.is_leaf()
        ]
        for x in xs:
            self.assertTrue(x in ws)
Пример #3
0
    def testContainer(self):
        """ Test container-like behaviour. """
        xs = [ TstO(r) for r in take(100,G.rect, 0.1) ]
        tree = RTree()
        for x in xs: 
            tree.insert(x,x.rect)
            self.invariants(tree)

        ws = [ x.leaf_obj() for x in tree.walk(lambda x,y: True) if x.is_leaf() ]
        self.invariants(tree)
        rrs = collections.defaultdict(int)
        
        for w in ws:
            rrs[w] = rrs[w] + 1

        for x in xs: self.assertEquals(rrs[x], 1)
Пример #4
0
    def testContainer(self):
        """ Test container-like behaviour. """
        xs = [TstO(r) for r in take(100, G.rect, 0.1)]
        tree = RTree()
        for x in xs:
            tree.insert(x, x.rect)
            self.invariants(tree)

        ws = [
            x.leaf_obj() for x in tree.walk(lambda x, y: True) if x.is_leaf()
        ]
        self.invariants(tree)
        rrs = collections.defaultdict(int)

        for w in ws:
            rrs[w] = rrs[w] + 1

        for x in xs:
            self.assertEquals(rrs[x], 1)