@classmethod<EOL><INDENT>def _validate_frequency(cls, index, freq, **kwargs):<DEDENT>
if is_period_dtype(cls):<EOL><INDENT>return None<EOL><DEDENT>inferred = index.inferred_freq<EOL>if index.size == <NUM_LIT:0> or inferred == freq.freqstr:<EOL><INDENT>return None<EOL><DEDENT>try:<EOL><INDENT>on_freq = cls._generate_range(start=index[<NUM_LIT:0>], end=None,<EOL>periods=len(index), freq=freq,<EOL>**kwargs)<EOL>if not np.array_equal(index.asi8, on_freq.asi8):<EOL><INDENT>raise ValueError<EOL><DEDENT><DEDENT>except ValueError as e:<EOL><INDENT>if "<STR_LIT>" in str(e):<EOL><INDENT>raise e<EOL><DEDENT>raise ValueError('<STR_LIT>'<EOL>'<STR_LIT>'<EOL>.format(infer=inferred, passed=freq.freqstr))<EOL><DEDENT>
Validate that a frequency is compatible with the values of a given
Datetime Array/Index or Timedelta Array/Index

Parameters
----------
index : DatetimeIndex or TimedeltaIndex
    The index on which to determine if the given frequency is valid
freq : DateOffset
    The frequency to validate