def _parse_rate(rate, hz_or_sec):
    """
    Parse rate into frequency and seconds

    Parameters
    ----------
    rate : str
        The pragma-specified rate

    hz_or_sec : str
        {'hz', 's'}

    Returns
    -------
    dict
        With keys {'seconds', 'frequency'}
    """
    try:
        rate = float(rate)
    except Exception:
        raise ValueError(f'Invalid rate: {rate}')
    if hz_or_sec == 'hz':
        freq, seconds = rate, 1.0 / rate
    elif hz_or_sec == 's':
        freq, seconds = 1.0 / rate, rate
    else:
        raise ValueError(f'Invalid hz_or_sec: {hz_or_sec}')
    return dict(frequency=int(freq) if int(freq) == freq else freq, seconds
        =int(seconds) if int(seconds) == seconds else seconds)
