def check_extension(path, ext):
    """
    Asserts that the given path ends with a specified extension.

    Parameters
    ----------
    path : str
        Path to file.
    ext : str
        File extension.

    Returns
    -------
    path : str
        Path with specified extension.

    """
    if not path.endswith(ext):
        if ext[0] == ".":
            path += ext
        else:
            path += "."+ext
    return path