Beispiel #1
0
    def print_one(
            wpt: Tuple[Tuple[str, str], Sequence[Tuple[str, int]]]) -> str:
        def print_inner(inner: Sequence[Tuple[str, int]]) -> str:
            def print_pair(pair: Tuple[str, int]) -> str:
                return fst(pair) + ' #= ' + str(snd(pair))

            return ' | '.join(list(map(print_pair, inner)))

        return fst(fst(wpt)) + '\t' + snd(fst(wpt)) + '\t' + print_inner(
            snd(wpt))
Beispiel #2
0
def sort_wpt(
    outer: Dict[Tuple[str, str], Dict[str, int]]
) -> List[Tuple[Tuple[str, str], Sequence[Tuple[str, int]]]]:
    outer = {
        outer_key: sorted(filter(lambda pair: snd(pair) > 0,
                                 inner_dict.items()),
                          key=lambda pair: snd(pair),
                          reverse=True)
        for outer_key, inner_dict in outer.items()
    }
    return sorted(outer.items(),
                  key=lambda pair: sum(list(map(snd, snd(pair)))))
Beispiel #3
0
def project_one_dag(dag: DAG) -> List[Sequence[str]]:
    leaves = set(filter(dag.is_leaf, dag.nodes))
    leaves = order_nodes(dag, leaves)
    leaves = list(map(lambda leaf: project_leaf(dag, leaf)[0:3], leaves))
    return list(
        map(
            lambda leaf:
            (fst(leaf), snd(leaf).depolarize().__str__(), last(leaf)), leaves))
Beispiel #4
0
 def print_pair(pair: Tuple[str, int]) -> str:
     return fst(pair) + ' #= ' + str(snd(pair))
Beispiel #5
0
 def getvalue(wtp: Sequence[str]) -> str:
     return snd(wtp)