def parse_float(src, key, nentries=1):
    """
    Parse a dictionary ``src`` and return a float or a list of float specified by ``key``. 
    This function checks that the value or values specified by ``key`` is of 
    type float or list of float and raises a ``ValueError`` otherwise.

    :param dict src: the source dictionary
    :param str key: the key specifing the directory name
    :param int nentries: the number of floats to parse
    :returns: read float(s)
    :rtype: float or list of float
    :raises ValueError: if the parsed values are not valid
    :raises KeyError: if the attribute ``key`` is not found in ``src``
    """

    if nentries < 1:
        raise ValueError('expected number of entries must be greater than zero')
    
    if key in src:
        val = src.get(key)
        if type(val) == float:
            if nentries != 1:
                msg = 'attribute ' + key + ' has 1 entry, expected ' + str(nentries)
                raise ValueError(msg)
            return val
        elif type(val) == list:
            nval = len(val)
            if nval != nentries:
                msg  = 'attribute ' + key + ' has ' + str(nval)
                msg += ' entries, expected ' + str(nentries)
                raise ValueError(msg)
            for m in range(0, nval):
                if type(val[m]) != float:                    
                    raise ValueError('entry ' + str(m + 1) + ' is not float')
            return val                            
        else:
            raise ValueError('attribute ' + key + ' is not of type float or list')
    else:
        raise KeyError('attribute not found!', key)