def pretty_file_size(size: float, precision: int = 2, align: str = ">",
                     width: int = 0) -> str:
    """Helper function to format size in human readable format.

    Parameters
    ----------
    size: float
        The size in bytes to be converted into human readable format.
    precision: int, optional
        Define shown precision.
    align: {'<', '^', '>'}, optional
        Format align specifier.
    width: int
        Define maximum width for number.

    Returns
    -------
    human_fmt: str
        Human readable representation of given `size`.

    Notes
    -----
    Credit to https://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size

    """  # noqa: E501

    template = "{size:{align}{width}.{precision}f} {unit}B"
    kwargs = dict(width=width, precision=precision, align=align)

    # iterate units (multiples of 1024 bytes)
    for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
        if abs(size) < 1024.0:
            return template.format(size=size, unit=unit, **kwargs)
        size /= 1024.0

    return template.format(size=size, unit='Yi', **kwargs)