Determines if two partitions have all nodes with identical attributes. Args: bp1: a BinaryPartition object to compare equality for bp2: the other BinaryPartition object to compare equality for Returns: A bool if all nodes in the partitions have equal attributes
(bp1: mp.BinaryPartition, bp2: mp.BinaryPartition)
| 286 | |
| 287 | |
| 288 | def partitions_are_equal(bp1: mp.BinaryPartition, bp2: mp.BinaryPartition) -> bool: |
| 289 | """Determines if two partitions have all nodes with identical attributes. |
| 290 | |
| 291 | Args: |
| 292 | bp1: a BinaryPartition object to compare equality for |
| 293 | bp2: the other BinaryPartition object to compare equality for |
| 294 | |
| 295 | Returns: |
| 296 | A bool if all nodes in the partitions have equal attributes |
| 297 | """ |
| 298 | if is_leaf_node(bp1) and is_leaf_node(bp2): |
| 299 | return bp1.proc_id == bp2.proc_id |
| 300 | elif (not is_leaf_node(bp1)) and (not is_leaf_node(bp2)): |
| 301 | return all( |
| 302 | [ |
| 303 | bp1.split_dir == bp2.split_dir, |
| 304 | bp1.split_pos == bp2.split_pos, |
| 305 | partitions_are_equal(bp1.left, bp2.left), |
| 306 | partitions_are_equal(bp1.right, bp2.right), |
| 307 | ] |
| 308 | ) |
| 309 | else: |
| 310 | return False |
nothing calls this directly
no test coverage detected