Пример #1
0
def parse_algorithms(options):
    """Return a list of initilized algorithms from the command line"""

    methods = options.method.split(",")
    methods = set(methods) - set([""])

    if options.quantiles:
        for sep in "-,":
            if sep in options.quantiles:
                q1, q2 = options.quantiles.split(sep, 1)
                break
        else:
            q1 = float(options.quantiles)
            q2 = 1.0 - q1
        quantiles = (float(q1), float(q2))

        if "quanties" not in methods:
            logger.warning(
                "Add quantiles to the set of methods as quantiles parameters is defined."
            )
            methods.add("quantiles")
    else:
        quantiles = None
        if "quantiles" in methods:
            logger.warning(
                "Quantiles method defined but no parameters set. Method skipped."
            )
            methods.remove("quantiles")

    if len(methods) == 0:
        logger.warning("No method defined. Add default mean method")
        methods.add("mean")

    result = []
    for method in methods:
        if not average.is_algorithm_name_exists(method):
            logger.warning("Method name '%s' unknown. Method skipped.", method)
            continue

        try:
            algorithm = average.create_algorithm(method, options.cutoff,
                                                 quantiles)
        except average.AlgorithmCreationError as e:
            logger.warning("Method '%s' skipped: %s", method, e)
            continue

        result.append(algorithm)

    return result
Пример #2
0
def parse_algorithms(options):
    """Return a list of initilized algorithms from the command line"""

    methods = options.method.split(",")
    methods = set(methods) - set([""])

    if options.quantiles:
        for sep in "-,":
            if sep in options.quantiles:
                q1, q2 = options.quantiles.split(sep, 1)
                break
        else:
            q1 = float(options.quantiles)
            q2 = 1.0 - q1
        quantiles = (float(q1), float(q2))

        if "quanties" not in methods:
            logger.warning("Add quantiles to the set of methods as quantiles parameters is defined.")
            methods.add("quantiles")
    else:
        quantiles = None
        if "quantiles" in methods:
            logger.warning("Quantiles method defined but no parameters set. Method skipped.")
            methods.remove("quantiles")

    if len(methods) == 0:
        logger.warning("No method defined. Add default mean method")
        methods.add("mean")

    result = []
    for method in methods:
        if not average.is_algorithm_name_exists(method):
            logger.warning("Method name '%s' unknown. Method skipped.")
            continue

        try:
            algorithm = average.create_algorithm(method, options.cutoff, quantiles)
        except average.AlgorithmCreationError as e:
            logger.warning("Method skipped: %s", e)
            continue

        result.append(algorithm)

    return result