def wrapper(*args, **kwargs) -> Any: if len(args) == 1 and gg.is_multiobjects(args[0]): args, = args outputs = cal_outpus(func, args, kwargs, type_check=self.type_check) if outputs is not None and gg.is_multiobjects(outputs) and len( outputs) == 1: outputs, = outputs return outputs
def cal_outpus(func: Callable, args: list, kwargs: dict, type_check: bool = True): if gg.is_multiobjects(args): if type_check: assert_same_type(*args) return tuple( cal_outpus(func, arg, kwargs, type_check=type_check) for arg in args) return func(args, **kwargs)
def parse_graph_inputs(*graph): if not graph: return None if isinstance(graph[0], gg.data.BaseGraph): ... elif isinstance(graph[0], dict): # TODO this could be a dict like ... elif sp.isspmatrix(graph[0]): graph = gg.data.Graph(*graph) elif gg.is_multiobjects(graph[0]): graph = gg.data.MultiGraph(*graph) else: raise ValueError(f"Unrecognized inputs {graph[0]}.") if len(graph) == 1: graph, = graph return graph