parameters: (cls, index, freq, **kwargs)
docstring: 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
docstring_summary: Validate that a frequency is compatible with the values of a given
          Datetime Array/Index or Timedelta Array/Index
docstring_tokens: Validate that a frequency is compatible with the values of a given Datetime Array / Index or Timedelta Array / Index
function: def _validate_frequency(cls, index, freq, **kwargs):
          """
          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
          """
          if is_period_dtype(cls):
              # Frequency validation is not meaningful for Period Array/Index
              return None
  
          inferred = index.inferred_freq
          if index.size == 0 or inferred == freq.freqstr:
              return None
  
          try:
              on_freq = cls._generate_range(
                  start=index[0], end=None, periods=len(index), freq=freq, **kwargs
              )
              if not np.array_equal(index.asi8, on_freq.asi8):
                  raise ValueError
          except ValueError as e:
              if "non-fixed" in str(e):
                  # non-fixed frequencies are not meaningful for timedelta64;
                  #  we retain that error message
                  raise e
              # GH#11587 the main way this is reached is if the `np.array_equal`
              #  check above is False.  This can also be reached if index[0]
              #  is `NaT`, in which case the call to `cls._generate_range` will
              #  raise a ValueError, which we re-raise with a more targeted
              #  message.
              raise ValueError(
                  f"Inferred frequency {inferred} from passed values "
                  f"does not conform to passed frequency {freq.freqstr}"
              )
function_tokens: def _validate_frequency ( cls , index , freq , * * kwargs ) : if is_period_dtype ( cls ) : # Frequency validation is not meaningful for Period Array/Index return None inferred = index . inferred_freq if index . size == 0 or inferred == freq . freqstr : return None try : on_freq = cls . _generate_range ( start = index [ 0 ] , end = None , periods = len ( index ) , freq = freq , * * kwargs ) if not np . array_equal ( index . asi8 , on_freq . asi8 ) : raise ValueError except ValueError as e : if "non-fixed" in str ( e ) : # non-fixed frequencies are not meaningful for timedelta64; #  we retain that error message raise e # GH#11587 the main way this is reached is if the `np.array_equal` #  check above is False.  This can also be reached if index[0] #  is `NaT`, in which case the call to `cls._generate_range` will #  raise a ValueError, which we re-raise with a more targeted #  message. raise ValueError ( f"Inferred frequency {inferred} from passed values " f"does not conform to passed frequency {freq.freqstr}" )