def tuples_almost_equal(t1, t2, path=""):
    """Compare two tuples, treating NaN floats as equal."""
    if len(t1) != len(t2):
        raise AssertionError(
            f"Tuple length mismatch at {path or 'root'}: {len(t1)} != {len(t2)}\n"
            f"  Left ({type(t1)}): {t1}\n"
            f"  Right ({type(t2)}): {t2}"
        )

    for i, (x, y) in enumerate(zip(t1, t2)):
        subpath = f"{path}[{i}]"
        if isinstance(x, tuple) and isinstance(y, tuple):
            tuples_almost_equal(x, y, path=subpath)
        elif not values_almost_equal(x, y):
            raise AssertionError(
                f"Mismatch at {subpath}:\n"
                f"  Left ({type(x)}): {x}\n"
                f"  Right ({type(y)}): {y}"
            )
Compare two tuples, treating NaN floats as equal.
tests/func/functions/test_array.py