Beispiel #1
0
 def wrapper(*args, **kwargs):
     if timed_pass.is_enabled():
         maybe_timed = timed_pass
     else:
         maybe_timed = lambda func, name: func
     try:
         # Pure function case
         graph, = args
         maybe_timed(graph.apply, func.__name__)(func, **kwargs)
     except ValueError:
         # Instance method case
         self, graph = args
         maybe_timed(graph.apply, func.__name__)(partial(func, self), **kwargs)
Beispiel #2
0
 def wrapper(*args):
     if timed_pass.is_enabled():
         maybe_timed = lambda *_args: timed_pass(func, func.__name__)(*_args
                                                                      )
     else:
         maybe_timed = lambda *_args: func(*_args)
     args = list(args)
     maybe_clusters = args.pop(0)
     if isinstance(maybe_clusters, Iterable):
         # Instance method
         processed = [maybe_timed(c, *args) for c in maybe_clusters]
     else:
         # Pure function
         self = maybe_clusters
         clusters = args.pop(0)
         processed = [maybe_timed(self, c, *args) for c in clusters]
     return flatten(processed)