Skip to content

Commit 43d24e5

Browse files
committed
Fix format order issue in quadtree __str__
The text was incorrect (allowed and actual depth were swapped) * pygorithm/data_structures/quadtree.py - fix __str__ * tests/test_data_structure.py - fix quadtree __str__ tests
1 parent b785d6f commit 43d24e5

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pygorithm/data_structures/quadtree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def __str__(self):
547547
_max_depth = max(_ents_per_depth.keys())
548548
_avg_ent_leaf = self.calculate_avg_ents_per_leaf()
549549
_mispl_weight = self.calculate_weight_misplaced_ents(sum_entities=_sum)
550-
return "quadtree(at {} with {} entities here ({} in total); (nodes, entities) per depth: {} (allowed max depth: {}, actual: {}), avg ent/leaf: {} (target {}), misplaced weight {} (0 best, >1 bad)".format(self.location, len(self.entities), _sum, _nodes_ents_per_depth_str, _max_depth, self.max_depth, _avg_ent_leaf, self.bucket_size, _mispl_weight)
550+
return "quadtree(at {} with {} entities here ({} in total); (nodes, entities) per depth: {} (allowed max depth: {}, actual: {}), avg ent/leaf: {} (target {}), misplaced weight {} (0 best, >1 bad)".format(self.location, len(self.entities), _sum, _nodes_ents_per_depth_str, self.max_depth, _max_depth, _avg_ent_leaf, self.bucket_size, _mispl_weight)
551551

552552
@staticmethod
553553
def get_code():

tests/test_data_structure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ def cleanup(self2=self):
784784

785785
self.addCleanup(cleanup)
786786
self.maxDiff = None
787-
self.assertEqual("quadtree(at rect(100x100 at <0, 0>) with 0 entities here (2 in total); (nodes, entities) per depth: [ 0: (1, 0), 1: (4, 2) ] (allowed max depth: 1, actual: 5), avg ent/leaf: 0.5 (target 1), misplaced weight 0.0 (0 best, >1 bad)", str(_tree))
787+
self.assertEqual("quadtree(at rect(100x100 at <0, 0>) with 0 entities here (2 in total); (nodes, entities) per depth: [ 0: (1, 0), 1: (4, 2) ] (allowed max depth: 5, actual: 1), avg ent/leaf: 0.5 (target 1), misplaced weight 0.0 (0 best, >1 bad)", str(_tree))
788788

789789
if __name__ == '__main__':
790790
unittest.main()

0 commit comments

Comments
 (0)