Ejemplo n.º 1
0
def equal_to(a, b):
    """
    Expected value comparator.

    Compares float values with math.isclose(),
    binary trees with equal_binary_trees(),
    and other types with == operator.
    """
    if isinstance(a, float) or isinstance(b, float):
        return math.isclose(a, b)
    import binary_tree_node
    import binary_tree_with_parent_prototype
    import bst_node
    from test_framework.binary_tree_utils import equal_binary_trees
    if (isinstance(a, binary_tree_node.BinaryTreeNode)
            or isinstance(a, binary_tree_with_parent_prototype.BinaryTreeNode)
            or isinstance(a, bst_node.BstNode)) and (
                isinstance(b, binary_tree_node.BinaryTreeNode) or isinstance(
                    b, binary_tree_with_parent_prototype.BinaryTreeNode)
                or isinstance(b, bst_node.BstNode)):
        return equal_binary_trees(a, b)
    return a == b
Ejemplo n.º 2
0
 def __eq__(self, other):
     return equal_binary_trees(self, other)
Ejemplo n.º 3
0
 def __eq__(self, other):
     return equal_binary_trees(self, other)