def _get_algorithm(self, algorithm_name): """ Get the specific algorithm. :param str algorithm_name: name of the algorithm to use(file name). :return: algorithm object. """ try: algorithm = anomaly_detector_algorithms[algorithm_name] return algorithm except KeyError: raise exceptions.AlgorithmNotFound('luminol.AnomalyDetector: ' + str(algorithm_name) + ' not found.')
def _get_algorithm_and_params(self, algorithm_name, algorithm_params): """ Get the specific algorithm and merge the algorithm params. :param str algorithm: name of the algorithm to use. :param dict algorithm_params: additional params for the specific algorithm. """ algorithm_name = algorithm_name or CORRELATOR_ALGORITHM try: self.algorithm = correlator_algorithms[algorithm_name] except KeyError: raise exceptions.AlgorithmNotFound('luminol.Correlator: ' + str(algorithm_name) + ' not found.') # Merge parameters. if algorithm_params: if not isinstance(algorithm_params, dict): raise exceptions.InvalidDataFormat( 'luminol.Correlator: algorithm_params passed is not a dictionary.' ) else: self.algorithm_params = dict(algorithm_params.items() + self.algorithm_params.items())