MCPcopy Create free account
hub / github.com/NanoComp/meep / partitions_are_equal

Function partitions_are_equal

python/binary_partition_utils.py:288–310  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

286
287
288def 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

Callers

nothing calls this directly

Calls 1

is_leaf_nodeFunction · 0.85

Tested by

no test coverage detected