def METHOD_NAME(fi, length, left_part):
    """
    Read raw bytes and convert them in integer.
    :param fi: A buffer containing the bytes to read.
    :param length: number of bytes to read.
    :type length: int or float
    :param left_part: If True, start the reading from the first half part
        of the byte.
    :type left_part: bool
    """
    if isinstance(length, float):
        if abs(length - 0.5) <= 1e-7:
            ints = np.frombuffer(fi.read(1), dtype='<u1')[0]
            if left_part is True:
                return np.bitwise_and(ints >> 4, 0x0f)
            else:
                return np.bitwise_and(ints, 0x0f)
        else:
            raise ValueError('invalid length of bytes to read.\
                             It has to be an integer or 0.5')
    else:
        return int(encode(fi.read(length), 'hex'), 16)