Пример #1
0
def consume_outputs(my_input: float, seed: int = 5) -> float:
    is_heads = coin_toss(seed=seed)
    res = (conditional("double_or_square").if_(is_heads.is_true()).then(
        square(n=my_input)).else_().then(calc_sum(a=my_input, b=my_input)))

    # Regardless of the result, call ``double`` before
    # the variable `res` is returned. In this case, ``res`` stores the value of the ``square`` or ``double`` of the variable `my_input`
    return double(n=res)
Пример #2
0
def merge_sort(numbers: typing.List[int],
               numbers_count: int,
               run_local_at_count: int = 10) -> typing.List[int]:
    return (conditional("terminal_case").if_(
        numbers_count <= run_local_at_count).then(
            sort_locally(numbers=numbers)).else_().then(
                merge_sort_remotely(numbers=numbers,
                                    run_local_at_count=run_local_at_count)))
Пример #3
0
def multiplier(my_input: float) -> float:
    return (
        conditional("fractions")
        .if_((my_input >= 0.1) & (my_input <= 1.0))
        .then(double(n=my_input))
        .else_()
        .then(square(n=my_input))
    )
def multiplier_3(my_input: float) -> float:
    d = (conditional("fractions").if_((my_input > 0.1)
                                      & (my_input < 1.0)).then(
                                          double(n=my_input)).
         elif_((my_input > 1.0) & (my_input < 10.0)).then(square(
             n=my_input)).else_().fail("The input must be between 0 and 10"))

    # d will be either the output of `double` or t he output of `square`. If the conditional() falls through the fail
    # branch, execution will not reach here.
    return double(n=d)
Пример #5
0
def multiplier_2(my_input: float) -> float:
    return (
        conditional("fractions")
        .if_((my_input > 0.1) & (my_input < 1.0))
        .then(double(n=my_input))
        .elif_((my_input > 1.0) & (my_input <= 10.0))
        .then(square(n=my_input))
        .else_()
        .fail("The input must be between 0 and 10")
    )
Пример #6
0
def multiplier_3(my_input: float) -> float:
    result = (
        conditional("fractions").if_((my_input > 0.1) & (my_input < 1.0)).then(
            double(
                n=my_input)).elif_((my_input > 1.0) & (my_input < 10.0)).then(
                    square(n=my_input)).else_().fail(
                        "The input must be between 0 and 10"))

    # the 'result' will either be the output of `double` or `square`. If none of the conditions is true,
    # it gives a failure message.
    return double(n=result)
Пример #7
0
def blast_wf(
    datadir: str = "data/kitasatospora",
    outdir: str = "output",
    query: str = "k_sp_CB01950_penicillin.fasta",
    db: str = "kitasatospora_proteins.faa",
    blast_output: str = "AMK19_00175_blastx_kitasatospora.tab",
) -> BLASTXOutput:
    stdout, blastout = blastx_on_shell(datadir=datadir,
                                       outdir=outdir,
                                       query=query,
                                       db=db,
                                       blast_output=blast_output)
    result = is_batchx_success(stdout=stdout)
    result, plot = (conditional("blastx_output").if_(result.is_true()).then(
        blastx_output(blastout=blastout)).else_().fail("BLASTX failed"))
    return BLASTXOutput(result=result, plot=plot)
def basic_boolean_wf() -> int:
    result = coin_toss()
    return (conditional("test").if_(result.is_true()).then(
        success()).else_().then(failed()))
Пример #9
0
def bool_input_wf(b: bool) -> int:
    return conditional("test").if_(b.is_true()).then(success()).else_().then(
        failed())