(self)
| 705 | self.assertDictEqual({ 0: 1, 1: 4, 2: 8 }, _tree.find_nodes_per_depth()) |
| 706 | |
| 707 | def test_sum_ents(self): |
| 708 | # it shouldn't matter where we put entities in, adding entities |
| 709 | # to a quadtree should increment this number by 1. So lets fuzz! |
| 710 | |
| 711 | _tree = quadtree.QuadTree(64, 5, self.big_rect) |
| 712 | for i in range(1000): |
| 713 | w = random.randrange(1, 10) |
| 714 | h = random.randrange(1, 10) |
| 715 | x = random.uniform(0, 1000 - w) |
| 716 | y = random.uniform(0, 1000 - h) |
| 717 | ent = quadtree.QuadTreeEntity(rect2.Rect2(w, h, vector2.Vector2(x, y))) |
| 718 | _tree.insert_and_think(ent) |
| 719 | |
| 720 | # avoid calculating sum every loop which would take way too long. |
| 721 | # on average, try to sum about 50 times total (5% of the time), |
| 722 | # evenly split between both ways of summing |
| 723 | rnd = random.random() |
| 724 | if rnd > 0.95 and rnd <= 0.975: |
| 725 | _sum = _tree.sum_entities() |
| 726 | self.assertEqual(i+1, _sum) |
| 727 | elif rnd > 0.975: |
| 728 | _sum = _tree.sum_entities(_tree.find_entities_per_depth()) |
| 729 | self.assertEqual(i+1, _sum) |
| 730 | |
| 731 | def test_avg_ents_per_leaf(self): |
| 732 | _tree = quadtree.QuadTree(3, 5, self.big_rect) |
nothing calls this directly
no test coverage detected