From 6f0703602270d03f4025221f13fee21aa842a863 Mon Sep 17 00:00:00 2001 From: Anthony LaTorre Date: Mon, 12 Sep 2011 16:41:17 -0400 Subject: add chroma-sim script. get rid of GPU class; contexts should now be created with create_cuda_context(). --- itertoolset.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'itertoolset.py') diff --git a/itertoolset.py b/itertoolset.py index 498b940..4d293e8 100644 --- a/itertoolset.py +++ b/itertoolset.py @@ -15,16 +15,16 @@ def peek(iterable): first_element = next(it) return first_element, chain([first_element], it) -def repeat_func(func, times=None, args=()): - "equivalent to (func(*args) for i in xrange(times))." +def repeatfunc(func, times=None, *args): + """Repeat calls to func with specified arguments. + + Example: repeatfunc(random.random) + """ if times is None: - while True: - yield func(*args) - else: - for i in xrange(times): - yield func(*args) + return starmap(func, repeat(args)) + return starmap(func, repeat(args, times)) -def repeat_copy(object, times=None): +def repeatcopy(object, times=None): """Returns deep copies of `object` over and over again. Runs indefinitely unless the `times` argument is specified.""" if times is None: -- cgit