- Timestamp:
- 11/20/12 14:46:46 (3 years ago)
- Location:
- branches/decorate
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/decorate/memoize.py
r595 r597 72 72 73 73 74 def shallow_round_factory(tol): 75 from numpy import round as around #XXX: try or numpy makes this slow 76 def shallow_round(*args, **kwds): 77 argstype = type(args) 78 _args = list(args) 79 _kwds = kwds.copy() 80 for i,j in enumerate(args): 81 try: 82 jtype = type(j) 83 _args[i] = jtype(around(j, tol)) 84 except: pass 85 for i,j in kwds.items(): 86 try: 87 jtype = type(j) 88 _kwds[i] = jtype(around(j, tol)) 89 except: pass 90 return argstype(_args), _kwds 91 return shallow_round 92 93 def shallow_round(tol=0): #NOTE: rounds floats, lists, arrays one level deep 94 def dec(f): 95 def func(*args, **kwds): 96 _shallow_round = shallow_round_factory(tol) 97 _args,_kwds = _shallow_round(*args, **kwds) 98 return f(*_args, **_kwds) 99 return func 100 return dec 101 102 74 103 def get_archive(archive): 75 104 import dill as pickle … … 135 164 if deep: rounded = deep_round 136 165 else: rounded = simple_round 166 #else: rounded = shallow_round 137 167 138 168 @rounded(tol) … … 166 196 if deep: rounded = deep_round 167 197 else: rounded = simple_round 198 #else: rounded = shallow_round 168 199 169 200 @rounded(tol) -
branches/decorate/surrogate.py
r595 r597 22 22 from memoize import memoized0_round, memoized0_nopickle_round 23 23 from memoize import memoized0_archived, memoized0_nopickle_archived 24 #@memoized0_round(0 )# slower, but more robust25 #@memoized0_nopickle_round(0 )26 #@memoized0_archived() # slower, but more robust24 #@memoized0_round(0, deep=True) # slower, but more robust 25 #@memoized0_nopickle_round(0, deep=True) 26 #@memoized0_archived() # slower, but more robust 27 27 @memoized0_nopickle_archived() 28 28 def marc_surr(x):
Note: See TracChangeset
for help on using the changeset viewer.