MCPcopy Create free account
hub / github.com/NanoComp/meep / memoize

Function memoize

python/geom.py:1676–1688  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

1674# Return a 'memoized' version of the function f, which caches its
1675# arguments and return values so as never to compute the same thing twice.
1676def memoize(f):
1677 f_memo_tab = {}
1678
1679 def _mem(y=None):
1680 tab_val = f_memo_tab.get(y, None)
1681 if tab_val:
1682 return tab_val
1683
1684 fy = f(y)
1685 f_memo_tab[y] = fy
1686 return fy
1687
1688 return _mem
1689
1690
1691# Find a root by Newton's method with bounds and bisection,

Callers 1

find_root_derivFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected