def _check_user_dims(dims_ntraces, ntraces):
    """Check that the lengths of the user-provided dimensions make sense."""
    if dims_ntraces > ntraces:
        raise ValueError(
            'supplied dimensions imply {} traces, but only {} in file'.
            format(dims_ntraces, ntraces))
    if dims_ntraces < 0:
        raise ValueError('supplied dimensions imply {} traces'.format(
            dims_ntraces))
    if dims_ntraces == 0 and ntraces > 0:
        raise ValueError('supplied dimensions imply {} traces, but {} in file'
            .format(dims_ntraces, ntraces))
    if dims_ntraces != 0 and ntraces % dims_ntraces != 0:
        raise ValueError(
            'supplied dimensions imply {} traces, but this does not divide into the {} traces in the file'
            .format(dims_ntraces, ntraces))
