def one_layer_tree_w_meta(head_op, *branch_ops, **bldargs): """ TODO """ funcmeata = {get_attr(head_op, **bldargs): tuple([get_attr(b_op, **bldargs) for b_op in branch_ops])} tree_func = one_layer_tree(head_op, *branch_ops, **bldargs) tree_func.funcmeta = funcmeata return tree_func
def tree_func(operand, *_, **runargs): runargs.update(bldargs) firstlayerres = [res for res in flatten_all_if_true(head_op(operand, *_, **runargs), **bldargs)] posteriordict = dict() for b_op in branch_ops: branchlist = [r for res in firstlayerres for r in list(flatten_all_if_true(b_op(res), **bldargs))] # Assumes each branch function will have a differant name. # Could end up being a big problem. posteriordict[get_attr(b_op, **bldargs)] = tuple(branchlist) return posteriordict