- Timestamp:
- 11/20/12 12:42:04 (3 years ago)
- Location:
- branches/UQ/math/legacy/envelope
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/UQ/math/legacy/envelope/Looper_BoLiSurr_Cy.py
r592 r596 119 119 120 120 # generate primary constraints function 121 # @memoized(tol=3 )121 # @memoized(tol=3, deep=True) 122 122 def constraints(rv): 123 123 rrv = range(len(rv)) -
branches/UQ/math/legacy/envelope/memoize.py
r592 r596 50 50 51 51 52 def simple_round_factory(tol): 53 def simple_round(*args, **kwds): 54 argstype = type(args) 55 _args = list(args) 56 _kwds = kwds.copy() 57 for i,j in enumerate(args): 58 if isinstance(j, float): _args[i] = round(j, tol) # don't round int 59 for i,j in kwds.items(): 60 if isinstance(j, float): _kwds[i] = round(j, tol) 61 return argstype(_args), _kwds 62 return simple_round 63 64 def simple_round(tol=0): #NOTE: only rounds floats, nothing else 65 def dec(f): 66 def func(*args, **kwds): 67 _simple_round = simple_round_factory(tol) 68 _args,_kwds = _simple_round(*args, **kwds) 69 return f(*_args, **_kwds) 70 return func 71 return dec 72 73 52 74 def get_archive(archive): 53 75 import dill as pickle … … 101 123 #FIXME: resolve signature difference... @memoized versus @memoized() 102 124 103 def memoized0_nopickle_round(tol=0 ):125 def memoized0_nopickle_round(tol=0, deep=False): 104 126 """Decorator that memoizes a function's return value each time it is called. 105 127 If called later with the same arguments, the memoized value is returned, and … … 111 133 memo = {} 112 134 113 @deep_round(tol) 135 if deep: rounded = deep_round 136 else: rounded = simple_round 137 138 @rounded(tol) 114 139 def rounded_args(*args, **kwds): 115 140 return (args, kwds) … … 130 155 131 156 132 def memoized0_round(tol=0 ):157 def memoized0_round(tol=0, deep=False): 133 158 """Decorator that memoizes a function's return value each time it is called. 134 159 If called later with the same arguments, the memoized value is returned, and … … 139 164 memo = {} 140 165 141 @deep_round(tol) 166 if deep: rounded = deep_round 167 else: rounded = simple_round 168 169 @rounded(tol) 142 170 def rounded_args(*args, **kwds): 143 171 return (args, kwds) -
branches/UQ/math/legacy/envelope/otm_hvi.py
r592 r596 33 33 from memoize import memoized0_nopickle_round as memoized 34 34 35 @memoized(tol=3 )35 @memoized(tol=3, deep=True) 36 36 def eureka(x, root_path="."): 37 37 """ Notes for now, will be fixed in the future!!! -
branches/UQ/math/legacy/envelope/otm_hvi_new.py
r592 r596 33 33 from memoize import memoized0_nopickle_round as memoized 34 34 35 @memoized(tol=3 )35 @memoized(tol=3, deep=True) 36 36 def eureka(x, root_path="."): 37 37 """ Notes for now, will be fixed in the future!!! -
branches/UQ/math/legacy/envelope/sausage.py
r592 r596 103 103 from memoize import memoized0_nopickle_round as memoized 104 104 # vectorize 'sausage_bounds' to find min/max for every evaluation point 105 @memoized(tol=3 )105 @memoized(tol=3, deep=True) 106 106 def model_sausage(x): 107 107 "find the boundary of the sausage in Y for the given x"
Note: See TracChangeset
for help on using the changeset viewer.