def strnbytes(nbytes):
    """
    Return number of bytes in a human readable unit of KiB, MiB or GiB.

    Parameter
    ---------
    nbytes: int
        Number of bytes, to be displayed in a human readable way.

    Example
    -------
    >>> a = np.empty((100,100))
    >>> strnbytes(a.nbytes)
    '78.125 KiB'

    """
    if nbytes < 1024:
        return str(nbytes) + ' bytes'
    elif nbytes < 1048576:
        return str(nbytes / 2 ** 10) + ' KiB'
    elif nbytes < 1073741824:
        return str(nbytes / 2 ** 20) + ' MiB'
    else:
        return str(nbytes / 2 ** 30) + ' GiB'
