- Timestamp:
- 10/24/15 08:43:05 (7 months ago)
- Location:
- mystic
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
mystic/examples/test_svc1.py
r835 r839 50 50 constrain = constraint(solvers(solve(constrain,target=['x0']))) 51 51 52 from mystic import sup ressed53 @sup ressed(1e-5)52 from mystic import suppressed 53 @suppressed(1e-5) 54 54 def conserve(x): 55 55 return constrain(x) -
mystic/examples/test_svc2.py
r835 r839 70 70 #constrain = constraint(solvers(solve(constrain))) 71 71 72 from mystic import sup ressed73 @sup ressed(5e-2)72 from mystic import suppressed 73 @suppressed(5e-2) 74 74 def conserve(x): 75 75 return constrain(x) -
mystic/examples/test_svr1.py
r835 r839 47 47 constrain = constraint(solvers(solve(constrain,target=['x0']))) 48 48 49 from mystic import sup ressed50 @sup ressed(1e-5)49 from mystic import suppressed 50 @suppressed(1e-5) 51 51 def conserve(x): 52 52 return constrain(x) -
mystic/examples/test_svr2.py
r830 r839 49 49 constrain = constraint(solvers(solve(constrain,target=['x0']))) 50 50 51 from mystic import sup ressed52 @sup ressed(1e-5)51 from mystic import suppressed 52 @suppressed(1e-5) 53 53 def conserve(x): 54 54 return constrain(x) -
mystic/examples_other/test_smo1.py
r829 r839 44 44 constrain = constraint(solvers(solve(constrain,target=['x0']))) 45 45 46 from mystic import sup ressed47 @sup ressed(1e-5)46 from mystic import suppressed 47 @suppressed(1e-5) 48 48 def conserve(x): 49 49 return constrain(x) -
mystic/mystic/_symbolic.py
r832 r839 268 268 nvars = None 269 269 permute = False # if True, return all permutations 270 warn = True # if True, don't sup ress warnings270 warn = True # if True, don't suppress warnings 271 271 verbose = False # if True, print debug info 272 272 #-----------------------undocumented------------------------------- … … 437 437 nvars = None 438 438 permute = False # if True, return all permutations 439 warn = True # if True, don't sup ress warnings439 warn = True # if True, don't suppress warnings 440 440 verbose = False # if True, print debug info 441 441 #-----------------------undocumented------------------------------- … … 635 635 #-----------------------undocumented------------------------------- 636 636 #kwds['permute'] = False # if True, return all permutations 637 kwds['warn'] = False # if True, don't sup ress warnings637 kwds['warn'] = False # if True, don't suppress warnings 638 638 kwds['verbose'] = False # if True, print debug info 639 639 #------------------------------------------------------------------ … … 704 704 nvars = None 705 705 permute = False # if True, return all permutations 706 warn = True # if True, don't sup ress warnings706 warn = True # if True, don't suppress warnings 707 707 verbose = False # if True, print details from _classify_variables 708 708 #-----------------------undocumented------------------------------- -
mystic/mystic/symbolic.py
r832 r839 198 198 after, before = eval(after, locals_), eval(before, locals_) 199 199 break 200 except ValueError as error: 200 except ValueError as error: #FIXME: python2.5 201 201 if error.message.startswith('negative number') and \ 202 202 error.message.endswith('raised to a fractional power'): -
mystic/mystic/tools.py
r826 r839 36 36 - insert_missing: return a sequence with the 'missing' elements inserted 37 37 - clipped: generate a function where values outside of bounds are clipped 38 - sup ressed: generate a function where values less than tol are supressed39 - sup ress: supress small values less than tol38 - suppressed: generate a function where values less than tol are suppressed 39 - suppress: suppress small values less than tol 40 40 - unpair: convert a 1D array of N pairs to two 1D arrays of N values 41 41 - src: extract source code from a python code object … … 381 381 if bounds: 382 382 def function_wrapper(x): 383 settings = seterr(all='ignore') #XXX: slow to sup ress warnings?383 settings = seterr(all='ignore') #XXX: slow to suppress warnings? 384 384 if any((x<min)|(x>max)): #if violate bounds, evaluate as inf 385 385 seterr(**settings) … … 568 568 569 569 570 def sup ress(x, tol=1e-8, clip=True):571 """sup ress small values less than tol"""570 def suppress(x, tol=1e-8, clip=True): 571 """suppress small values less than tol""" 572 572 from numpy import asarray, abs 573 573 x = asarray(list(x)) 574 574 mask = abs(x) < tol 575 575 if not clip: 576 # preserve sum by spreading sup ressed values to the non-zero elements576 # preserve sum by spreading suppressed values to the non-zero elements 577 577 x[mask==False] = (x + sum(x[mask])/(len(mask)-sum(mask)))[mask==False] 578 578 x[mask] = 0.0 579 579 return x.tolist() 580 580 581 def sup ressed(tol=1e-8, exit=False, clip=True):582 """generate a function, where values less than tol are sup ressed581 def suppressed(tol=1e-8, exit=False, clip=True): 582 """generate a function, where values less than tol are suppressed 583 583 584 584 For example, 585 >>> @sup ressed(1e-8)585 >>> @suppressed(1e-8) 586 586 ... def square(x): 587 587 ... return [i**2 for i in x] … … 591 591 >>> 592 592 >>> from mystic.math.measures import normalize 593 >>> @sup ressed(1e-8, exit=True, clip=False)593 >>> @suppressed(1e-8, exit=True, clip=False) 594 594 ... def norm(x): 595 595 ... return normalize(x, mass=1) … … 603 603 if exit: 604 604 def func(x, *args, **kwds): 605 return sup ress(f(x, *args, **kwds), tol, clip)605 return suppress(f(x, *args, **kwds), tol, clip) 606 606 else: 607 607 def func(x, *args, **kwds): 608 return f(sup ress(x, tol, clip), *args, **kwds)608 return f(suppress(x, tol, clip), *args, **kwds) 609 609 func.__wrapped__ = f 610 610 func.__doc__ = f.__doc__
Note: See TracChangeset
for help on using the changeset viewer.