From 9e766d03559c546e31693e0f5ecd2e7bc0f9fa98 Mon Sep 17 00:00:00 2001 From: Stephen Mardson McQuay Date: Sat, 7 May 2011 16:06:14 -0600 Subject: [PATCH] added a better docstring and improved the memoize function --- interp/baker/__init__.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/interp/baker/__init__.py b/interp/baker/__init__.py index eea94d7..26392c3 100644 --- a/interp/baker/__init__.py +++ b/interp/baker/__init__.py @@ -196,10 +196,11 @@ def memoize(f): """ cache = {} @wraps(f) - def memf(*x, **kargs): + def memf(simplex_size, nu): + x = (simplex_size, nu) if x not in cache: log.debug("adding to cache: %s", x) - cache[x] = f(*x, **kargs) + cache[x] = f(simplex_size, nu) return cache[x] return memf @@ -207,7 +208,8 @@ def memoize(f): @memoize def pattern(simplex_size, nu): """ - my useful docstring + This function returns the pattern requisite to compose the error + approximation function, and the matrix B. """ log.debug("pattern: simplex: %d, order: %d" % (simplex_size, nu)) @@ -215,7 +217,8 @@ def pattern(simplex_size, nu): for i in itertools.product(xrange(simplex_size), repeat = nu): if len(set(i)) !=1: r.append(tuple(sorted(i))) - return list(set(r)) + unique_r = list(set(r)) + return unique_r if __name__ == '__main__':