def _valid_frequency()

in kats/detectors/hourly_ratio_detection.py [0:0]


    def _valid_frequency(self) -> None:
        """Valid frequency of the input timeseries.

        If freq is given by user, then use the freq defined by user, otherwise we use ts.infer_freq_robust() to infer data frequencey.
        Data freq should be at least hourly level. For data with the granularity finner than hourly level, aggregate function should be given using aggregate attribuate.
        Now only support aggregation functions: min, max, sum, mean.
        """

        lower_granularity = ["T", "S", "L", "U", "N"]
        if self.freq is None:
            self.freq = self.data.infer_freq_robust()
        if self.freq == "H" or (
            isinstance(self.freq, pd.Timedelta) and self.freq.value == 3600000000000
        ):
            msg = "Input data is hourly data."
            logging.info(msg)
            return
        if isinstance(self.freq, str):
            for level in lower_granularity:
                if isinstance(self.freq, str) and level in self.freq:
                    msg = "Input data granularity is {} and we can continue processing using aggregation function.".format(
                        self.freq
                    )
                    logging.info(msg)
        elif isinstance(self.freq, pd.Timedelta) and self.freq.value < 3600000000000:
            pass
        else:
            msg = "Time series should be of hourly or finer granularity."
            logging.error(msg)
            raise ValueError(msg)

        if self.aggregate is None:
            msg = "Aggregation method is missing."
            logging.error(msg)
            raise ValueError(msg)
        elif self.aggregate in ["min", "max", "sum", "mean"]:
            msg = "Aggregation method is {}.".format(self.aggregate)
            logging.info(msg)
            return
        else:
            msg = "Aggregation methd {} is not implemented.".format(self.aggregate)
            logging.error(msg)
            raise ValueError(msg)