added a better docstring and improved the memoize function
This commit is contained in:
parent
cbe1a778c9
commit
9e766d0355
@ -196,10 +196,11 @@ def memoize(f):
|
|||||||
"""
|
"""
|
||||||
cache = {}
|
cache = {}
|
||||||
@wraps(f)
|
@wraps(f)
|
||||||
def memf(*x, **kargs):
|
def memf(simplex_size, nu):
|
||||||
|
x = (simplex_size, nu)
|
||||||
if x not in cache:
|
if x not in cache:
|
||||||
log.debug("adding to cache: %s", x)
|
log.debug("adding to cache: %s", x)
|
||||||
cache[x] = f(*x, **kargs)
|
cache[x] = f(simplex_size, nu)
|
||||||
return cache[x]
|
return cache[x]
|
||||||
return memf
|
return memf
|
||||||
|
|
||||||
@ -207,7 +208,8 @@ def memoize(f):
|
|||||||
@memoize
|
@memoize
|
||||||
def pattern(simplex_size, nu):
|
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))
|
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):
|
for i in itertools.product(xrange(simplex_size), repeat = nu):
|
||||||
if len(set(i)) !=1:
|
if len(set(i)) !=1:
|
||||||
r.append(tuple(sorted(i)))
|
r.append(tuple(sorted(i)))
|
||||||
return list(set(r))
|
unique_r = list(set(r))
|
||||||
|
return unique_r
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user