rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
self.lower[self.lower == numpy.NINF] = -_double_max
self.lower = where(self.lower == numpy.NINF, -_double_max, self.lower)
def init(self, **options): self.__dict__.update(options) self.lower = asarray(self.lower) self.lower[self.lower == numpy.NINF] = -_double_max self.upper = asarray(self.upper) self.upper[self.upper == numpy.PINF] = _double_max self.k = 0 self.accepted = 0 self.feval = 0 self.tests = 0
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
self.upper[self.upper == numpy.PINF] = _double_max
self.upper = where(self.upper == numpy.PINF, _double_max, self.upper)
def init(self, **options): self.__dict__.update(options) self.lower = asarray(self.lower) self.lower[self.lower == numpy.NINF] = -_double_max self.upper = asarray(self.upper) self.upper[self.upper == numpy.PINF] = _double_max self.k = 0 self.accepted = 0 self.feval = 0 self.tests = 0
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
def update_guess(self, x0): std = minimum(sqrt(self.T)*ones(self.dims), (self.upper-self.lower)/3.0/self.learn_rate) x0 = asarray(x0) #xc = squeeze(random.normal(0, std*self.learn_rate, size=self.dims)) xc = squeeze(random.normal(0, 1.0, size=self.dims)) xnew = x0 + xc*std*self.learn_rate return xnew
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
iter = 0
iters = 0
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
iter += 1
iters += 1
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
if (iter > maxiter):
if (iters > maxiter):
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
schedule.feval, iter, schedule.accepted, retval
schedule.feval, iters, schedule.accepted, retval
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
cdc22b7f935df58d1b69463351bbb112522c34e1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cdc22b7f935df58d1b69463351bbb112522c34e1/anneal.py
indx = numpy.argsort( perm ) return numpy.take( flag, indx[:len( ar1 )] )
ii = numpy.where( flag * aux2 ) aux = perm[ii+1] perm[ii+1] = perm[ii] perm[ii] = aux indx = numpy.argsort( perm )[:len( ar1 )] return numpy.take( flag, indx )
def setmember1d( ar1, ar2 ): """Return an array of shape of ar1 containing 1 where the elements of ar1 are in ar2 and 0 otherwise.""" ar = numpy.concatenate( (ar1, ar2 ) ) perm = numpy.argsort( ar ) aux = numpy.take( ar, perm ) flag = ediff1d( aux, 1 ) == 0 indx = numpy.argsort( perm ) return numpy.take( flag, indx[:le...
70bf077d4de719bbe527ecd1eb60e7c0c2b2957b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/70bf077d4de719bbe527ecd1eb60e7c0c2b2957b/arraysetops.py
if hasattr(object, '_ppimport_attr'):
if hasattr(object,'_ppimport_importer') or \ hasattr(object, '_ppimport_module'): object = object._ppimport_module elif hasattr(object, '_ppimport_attr'):
def info(object=None,maxwidth=76,output=sys.stdout,): """Get help information for a function, class, or module. Example: >>> from scipy import * >>> info(polyval) polyval(p, x) Evaluate the polymnomial p at x. Description: If p is of length N, this function returns the value: p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[...
04673d0b178cfe7f3719b4aaef1842210027fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/04673d0b178cfe7f3719b4aaef1842210027fdb3/helpmod.py
elif hasattr(object,'_ppimport_importer') or \ hasattr(object, '_ppimport_module'): object = object._ppimport_module
def info(object=None,maxwidth=76,output=sys.stdout,): """Get help information for a function, class, or module. Example: >>> from scipy import * >>> info(polyval) polyval(p, x) Evaluate the polymnomial p at x. Description: If p is of length N, this function returns the value: p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[...
04673d0b178cfe7f3719b4aaef1842210027fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/04673d0b178cfe7f3719b4aaef1842210027fdb3/helpmod.py
if hasattr(a,'_ppimport_module') or \ hasattr(a,'_ppimport_importer'):
if hasattr(a,'_ppimport_importer') or \ hasattr(a,'_ppimport_module'):
def __call__ (self, *args, **kwds): new_args = [] for a in args: if hasattr(a,'_ppimport_module') or \
04673d0b178cfe7f3719b4aaef1842210027fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/04673d0b178cfe7f3719b4aaef1842210027fdb3/helpmod.py
if hasattr(a,'_ppimport_attr'):
if hasattr(a,'_ppimport_attr'):
def __call__ (self, *args, **kwds): new_args = [] for a in args: if hasattr(a,'_ppimport_module') or \
04673d0b178cfe7f3719b4aaef1842210027fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/04673d0b178cfe7f3719b4aaef1842210027fdb3/helpmod.py
object = object._ppimport_module if hasattr(object,'_ppimport_attr'):
object = object._ppimport_module if hasattr(object,'_ppimport_attr'):
def _inspect_getfile(object):
04673d0b178cfe7f3719b4aaef1842210027fdb3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/04673d0b178cfe7f3719b4aaef1842210027fdb3/helpmod.py
def nnlf(self, *args):
def nnlf(self, theta, x):
def nnlf(self, *args): # - sum (log pdf(x, theta)) # where theta are the parameters (including loc and scale) # try: x = args[-1] loc = args[-2] scale = args[-3] args = args[:-3] except IndexError: raise ValueError, "Not enough input arguments." if not self._argcheck(*args) or scale <= 0: return inf x = arr((x-loc) /...
4fc3c3382d4f39d6cb250f55b2b024d3eef437e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/4fc3c3382d4f39d6cb250f55b2b024d3eef437e9/distributions.py
x = args[-1] loc = args[-2] scale = args[-3] args = args[:-3]
loc = theta[-2] scale = theta[-1] args = tuple(theta[:-2])
def nnlf(self, *args): # - sum (log pdf(x, theta)) # where theta are the parameters (including loc and scale) # try: x = args[-1] loc = args[-2] scale = args[-3] args = args[:-3] except IndexError: raise ValueError, "Not enough input arguments." if not self._argcheck(*args) or scale <= 0: return inf x = arr((x-loc) /...
4fc3c3382d4f39d6cb250f55b2b024d3eef437e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/4fc3c3382d4f39d6cb250f55b2b024d3eef437e9/distributions.py
return self._nnlf(self, x, *args) + N*log(scale)
return self._nnlf(x, *args) + N*log(scale)
def nnlf(self, *args): # - sum (log pdf(x, theta)) # where theta are the parameters (including loc and scale) # try: x = args[-1] loc = args[-2] scale = args[-3] args = args[:-3] except IndexError: raise ValueError, "Not enough input arguments." if not self._argcheck(*args) or scale <= 0: return inf x = arr((x-loc) /...
4fc3c3382d4f39d6cb250f55b2b024d3eef437e9 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/4fc3c3382d4f39d6cb250f55b2b024d3eef437e9/distributions.py
nzmax = 0
try: nzmax = self.nnz except AtrributeError: nzmax = 0
def getnzmax(self): try: nzmax = self.nzmax except AttributeError: nzmax = 0 return nzmax
fcf4244ef83d409592ec270ea7ac7c461892444e /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/fcf4244ef83d409592ec270ea7ac7c461892444e/Sparse.py
self.vecfunc = sgf(self._single_call)
self.vecfunc = sgf(self._single_call,otypes='d')
def __init__(self, dist, xa=-10.0, xb=10.0, xtol=1e-14): self.dist = dist self.cdf = eval('%scdf'%dist) self.xa = xa self.xb = xb self.xtol = xtol self.vecfunc = sgf(self._single_call)
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
def argsreduce(cond, *args): """Return a sequence of arguments converted to the dimensions of cond """ newargs = list(args) expand_arr = (cond==cond) for k in range(len(args)): newargs[k] = extract(cond,arr(args[k])*expand_arr) return newargs
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self.vecfunc = sgf(self._ppf_single_call) self.vecentropy = sgf(self._entropy)
self.vecfunc = sgf(self._ppf_single_call,otypes='d') self.vecentropy = sgf(self._entropy,otypes='d') self.veccdf = sgf(self._cdf_single_call,otypes='d')
def __init__(self, momtype=1, a=None, b=None, xa=-10.0, xb=10.0, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = nan self.badvalue = badvalue self.name = name self.a = a self.b = b if a is None: self.a = -scipy.inf if b is None: self.b = scipy.inf self.x...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self.generic_moment = sgf(self._mom0_sc)
self.generic_moment = sgf(self._mom0_sc,otypes='d')
def __init__(self, momtype=1, a=None, b=None, xa=-10.0, xb=10.0, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = nan self.badvalue = badvalue self.name = name self.a = a self.b = b if a is None: self.a = -scipy.inf if b is None: self.b = scipy.inf self.x...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self.generic_moment = sgf(self._mom1_sc)
self.generic_moment = sgf(self._mom1_sc,otypes='d')
def __init__(self, momtype=1, a=None, b=None, xa=-10.0, xb=10.0, xtol=1e-14, badvalue=None, name=None, longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = nan self.badvalue = badvalue self.name = name self.a = a self.b = b if a is None: self.a = -scipy.inf if b is None: self.b = scipy.inf self.x...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
def _cdf_single_call(self, x, *args): return scipy.integrate.quad(self._pdf, self.a, x, args=args)[0]
def _rvs(self, *args): ## Use basic inverse cdf algorithm for RV generation as default. U = rand.sample(self._size) Y = self._ppf(U,*args) return Y
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
return scipy.integrate.quad(self._pdf, self.a, x, args=args)[0]
return self.veccdf(x,*args)
def _cdf(self, x, *args): return scipy.integrate.quad(self._pdf, self.a, x, args=args)[0]
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
insert(output,(1-cond0)*(cond1==cond1), self.badvalue)
insert(output,(1-cond0)+(1-cond1)*(q!=0.0), self.badvalue)
def ppf(self,q,*args,**kwds): """Percent point function (inverse of cdf) at q of the given RV.
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self._cdfvec = sgf(self._cdfsingle)
self._cdfvec = sgf(self._cdfsingle,otypes='d')
def __init__(self, a=0, b=scipy.inf, name=None, badvalue=None, moment_tol=1e-8,values=None,inc=1,longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = scipy.nan self.badvalue = badvalue self.a = a self.b = b self.invcdf_a = a self.invcdf_b = b self.name = name self.moment_tol = moment_tol self.inc...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self._ppf = new.instancemethod(sgf(_drv_ppf), self, rv_discrete) self._pmf = new.instancemethod(sgf(_drv_pmf), self, rv_discrete) self._cdf = new.instancemethod(sgf(_drv_cdf), self, rv_discrete)
self._ppf = new.instancemethod(sgf(_drv_ppf,otypes='d'), self, rv_discrete) self._pmf = new.instancemethod(sgf(_drv_pmf,otypes='d'), self, rv_discrete) self._cdf = new.instancemethod(sgf(_drv_cdf,otypes='d'), self, rv_discrete)
def __init__(self, a=0, b=scipy.inf, name=None, badvalue=None, moment_tol=1e-8,values=None,inc=1,longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = scipy.nan self.badvalue = badvalue self.a = a self.b = b self.invcdf_a = a self.invcdf_b = b self.name = name self.moment_tol = moment_tol self.inc...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self._vecppf = new.instancemethod(sgf(_drv2_ppfsingle),
self._vecppf = new.instancemethod(sgf(_drv2_ppfsingle,otypes='d'),
def __init__(self, a=0, b=scipy.inf, name=None, badvalue=None, moment_tol=1e-8,values=None,inc=1,longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = scipy.nan self.badvalue = badvalue self.a = a self.b = b self.invcdf_a = a self.invcdf_b = b self.name = name self.moment_tol = moment_tol self.inc...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
self.generic_moment = new.instancemethod(sgf(_drv2_moment),
self.generic_moment = new.instancemethod(sgf(_drv2_moment, otypes='d'),
def __init__(self, a=0, b=scipy.inf, name=None, badvalue=None, moment_tol=1e-8,values=None,inc=1,longname=None, shapes=None, extradoc=None): if badvalue is None: badvalue = scipy.nan self.badvalue = badvalue self.a = a self.b = b self.invcdf_a = a self.invcdf_b = b self.name = name self.moment_tol = moment_tol self.inc...
6db89fd66aa882d8bb85d064d95c26c6ce2fcc55 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6db89fd66aa882d8bb85d064d95c26c6ce2fcc55/distributions.py
Numeric_solve = linalg.solve_linear_equations
basic_solve = linalg.solve_linear_equations
def bench_random(self,level=5): from scipy.basic import linalg Numeric_solve = linalg.solve_linear_equations print print ' Solving system of linear equations' print ' =================================='
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
assert not a.iscontiguous()
assert not a.flags['CONTIGUOUS']
def bench_random(self,level=5): from scipy.basic import linalg Numeric_solve = linalg.solve_linear_equations print print ' Solving system of linear equations' print ' =================================='
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
Numeric_inv = linalg.inverse
basic_inv = linalg.inverse
def bench_random(self,level=5): from scipy.basic import linalg Numeric_inv = linalg.inverse print print ' Finding matrix inverse' print ' ==================================' print ' | contiguous | non-contiguous ' print '----------------------------------------------' print ' size | scipy ...
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
assert not a.iscontiguous()
assert not a.flags['CONTIGUOUS']
def bench_random(self,level=5): from scipy.basic import linalg Numeric_inv = linalg.inverse print print ' Finding matrix inverse' print ' ==================================' print ' | contiguous | non-contiguous ' print '----------------------------------------------' print ' size | scipy ...
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
Numeric_det = linalg.determinant
basic_det = linalg.determinant
def check_random(self): from scipy.basic import linalg Numeric_det = linalg.determinant n = 20 for i in range(4): a = random([n,n]) d1 = det(a) d2 = Numeric_det(a) assert_almost_equal(d1,d2)
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
d2 = Numeric_det(a)
d2 = basic_det(a)
def check_random(self): from scipy.basic import linalg Numeric_det = linalg.determinant n = 20 for i in range(4): a = random([n,n]) d1 = det(a) d2 = Numeric_det(a) assert_almost_equal(d1,d2)
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
Numeric_det = linalg.determinant
basic_det = linalg.determinant
def check_random_complex(self): from scipy.basic import linalg Numeric_det = linalg.determinant n = 20 for i in range(4): a = random([n,n]) + 2j*random([n,n]) d1 = det(a) d2 = Numeric_det(a) assert_almost_equal(d1,d2)
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
d2 = Numeric_det(a)
d2 = basic_det(a)
def check_random_complex(self): from scipy.basic import linalg Numeric_det = linalg.determinant n = 20 for i in range(4): a = random([n,n]) + 2j*random([n,n]) d1 = det(a) d2 = Numeric_det(a) assert_almost_equal(d1,d2)
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
Numeric_det = linalg.determinant
basic_det = linalg.determinant
def bench_random(self,level=5): from scipy.basic import linalg Numeric_det = linalg.determinant print print ' Finding matrix determinant' print ' ==================================' print ' | contiguous | non-contiguous ' print '----------------------------------------------' print ' size |...
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
assert not a.iscontiguous()
assert not a.flags['CONTIGUOUS']
def bench_random(self,level=5): from scipy.basic import linalg Numeric_det = linalg.determinant print print ' Finding matrix determinant' print ' ==================================' print ' | contiguous | non-contiguous ' print '----------------------------------------------' print ' size |...
7a2c431004271fb01e28862a93afb11b83c27914 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/7a2c431004271fb01e28862a93afb11b83c27914/test_basic.py
indx = cols[:,newaxis]*ones((1,rN)) + \ rows[newaxis,:]*ones((cN,1)) - 1
indx = cols[:,newaxis]*ones((1,rN),dtype=int) + \ rows[newaxis,:]*ones((cN,1),dtype=int) - 1
def toeplitz(c,r=None): """ Construct a toeplitz matrix (i.e. a matrix with constant diagonals). Description: toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first column and r as its first row. toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). See also: hankel """ isscalar = numpy.isscal...
8d00c8ba3be23f175397c10a9c5aaf91cc8ce1ad /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8d00c8ba3be23f175397c10a9c5aaf91cc8ce1ad/basic.py
indx = cols[:,newaxis]*ones((1,rN)) + \ rows[newaxis,:]*ones((cN,1)) - 1
indx = cols[:,newaxis]*ones((1,rN),dtype=int) + \ rows[newaxis,:]*ones((cN,1),dtype=int) - 1
def hankel(c,r=None): """ Construct a hankel matrix (i.e. matrix with constant anti-diagonals). Description: hankel(c,r) is a Hankel matrix whose first column is c and whose last row is r. hankel(c) is a square Hankel matrix whose first column is C. Elements below the first anti-diagonal are zero. See also: toepli...
8d00c8ba3be23f175397c10a9c5aaf91cc8ce1ad /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8d00c8ba3be23f175397c10a9c5aaf91cc8ce1ad/basic.py
lfit = Results(L.lstsq(self.wdesign, Z)[0])
lfit = Results(L.lstsq(self.wdesign, Z)[0], Y)
def est_coef(self, Y): """ Estimate coefficients using lstsq, returning fitted values, Y and coefficients, but initialize is not called so no psuedo-inverse is calculated. """ Z = self.whiten(Y)
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
lfit.Y = Y
def est_coef(self, Y): """ Estimate coefficients using lstsq, returning fitted values, Y and coefficients, but initialize is not called so no psuedo-inverse is calculated. """ Z = self.whiten(Y)
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
lfit = Results(N.dot(self.calc_beta, Z),
lfit = Results(N.dot(self.calc_beta, Z), Y,
def fit(self, Y, **keywords): """ Full \'fit\' of the model including estimate of covariance matrix, (whitened) residuals and scale.
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
lfit.Y = Y
def fit(self, Y, **keywords): """ Full \'fit\' of the model including estimate of covariance matrix, (whitened) residuals and scale.
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
def norm_resid(self): """ Residuals, normalized to have unit length.
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
norm_resid = self.resid * N.multiply.outer(N.ones(Y.shape[0]), sdd)
norm_resid = self.resid * N.multiply.outer(N.ones(self.Y.shape[0]), sdd)
def norm_resid(self): """ Residuals, normalized to have unit length.
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
if not adjusted: ratio *= ((Y.shape[0] - 1) / self.df_resid)
if not adjusted: ratio *= ((self.Y.shape[0] - 1) / self.df_resid)
def Rsq(self, adjusted=False): """ Return the R^2 value for each row of the response Y. """ self.Ssq = N.std(self.Z,axis=0)**2 ratio = self.scale / self.Ssq if not adjusted: ratio *= ((Y.shape[0] - 1) / self.df_resid) return 1 - ratio
af7b6951110ce17903406fde26c729dadde75f31 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/af7b6951110ce17903406fde26c729dadde75f31/regression.py
from scipy.misc import _common_type ct = _common_type(obs,code_book)
from scipy.misc import x_common_type ct = x_common_type(obs,code_book)
def vq(obs,code_book): """ Vector Quantization: assign features sets to codes in a code book. Description: Vector quantization determines which code in the code book best represents an observation of a target. The features of each observation are compared to each code in the book, and assigned the one closest to it. ...
66282068cbd84edcddaa490e8207299a4f99045a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/66282068cbd84edcddaa490e8207299a4f99045a/vq.py
print 'py'
def vq(obs,code_book): """ Vector Quantization: assign features sets to codes in a code book. Description: Vector quantization determines which code in the code book best represents an observation of a target. The features of each observation are compared to each code in the book, and assigned the one closest to it. ...
66282068cbd84edcddaa490e8207299a4f99045a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/66282068cbd84edcddaa490e8207299a4f99045a/vq.py
im = asarray(im)
im = MLab.asarray(im)
def wiener(im,mysize=None,noise=None): """Perform a wiener filter on an N-dimensional array. Description: Apply a wiener filter to the N-dimensional array in. Inputs: in -- an N-dimensional array. kernel_size -- A scalar or an N-length list giving the size of the median filter window in each dimension. Elements of...
c025bc502e82aee214768daca0484b6ed89d9139 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/c025bc502e82aee214768daca0484b6ed89d9139/signaltools.py
lMean = correlate(im,ones(mysize),1) / MLab.prod(mysize)
lMean = correlate(im,MLab.ones(mysize),1) / MLab.prod(mysize)
def wiener(im,mysize=None,noise=None): """Perform a wiener filter on an N-dimensional array. Description: Apply a wiener filter to the N-dimensional array in. Inputs: in -- an N-dimensional array. kernel_size -- A scalar or an N-length list giving the size of the median filter window in each dimension. Elements of...
c025bc502e82aee214768daca0484b6ed89d9139 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/c025bc502e82aee214768daca0484b6ed89d9139/signaltools.py
lVar = correlate(im**2,ones(mysize),1) / MLab.prod(mysize) - lMean**2
lVar = correlate(im**2,MLab.ones(mysize),1) / MLab.prod(mysize) - lMean**2
def wiener(im,mysize=None,noise=None): """Perform a wiener filter on an N-dimensional array. Description: Apply a wiener filter to the N-dimensional array in. Inputs: in -- an N-dimensional array. kernel_size -- A scalar or an N-length list giving the size of the median filter window in each dimension. Elements of...
c025bc502e82aee214768daca0484b6ed89d9139 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/c025bc502e82aee214768daca0484b6ed89d9139/signaltools.py
noise = MLab.mean(ravel(lVar))
noise = MLab.mean(MLab.ravel(lVar))
def wiener(im,mysize=None,noise=None): """Perform a wiener filter on an N-dimensional array. Description: Apply a wiener filter to the N-dimensional array in. Inputs: in -- an N-dimensional array. kernel_size -- A scalar or an N-length list giving the size of the median filter window in each dimension. Elements of...
c025bc502e82aee214768daca0484b6ed89d9139 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/c025bc502e82aee214768daca0484b6ed89d9139/signaltools.py
gist.plsys(savesys)
if savesys > 0: gist.plsys(savesys)
def plot(x,*args,**keywds): """Plot curves. Description: Plot one or more curves on the same graph. Inputs: There can be a variable number of inputs which consist of pairs or triples. The second variable is plotted against the first using the linetype specified by the optional third variable in the triple. If onl...
f8186bdf4dbe42c50f54cf3a0062b5bc67aa51d8 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/f8186bdf4dbe42c50f54cf3a0062b5bc67aa51d8/Mplot.py
[4, 0.5+4, 5./6+4, 1./9, (0.75)**4*sqrt(pi)* gamma(5./6+2./3*4)/gamma(0.5+4./3)*gamma(5./6+4./3)],
[5, 2, 5-2+1, -1, 1./2**5*sqrt(pi)* gamma(1+5-2)/gamma(1+0.5*5-2)/gamma(0.5+0.5*5)], [4, 0.5+4, 1.5-2*4, -1./3, (8./9)**(-2*4)*gamma(4./3)* gamma(1.5-2*4)/gamma(3./2)/gamma(4./3-2*4)],
def check_hyp2f1(self): # a collection of special cases taken from AMS 55 values = [[0.5, 1, 1.5, 0.2**2, 0.5/0.2*log((1+0.2)/(1-0.2))], [0.5, 1, 1.5, -0.2**2, 1./0.2*arctan(0.2)], [1, 1, 2, 0.2, -1/0.2*log(1-0.2)], [3, 3.5, 1.5, 0.2**2, 0.5/0.2/(-5)*((1+0.2)**(-5)-(1-0.2)**(-5))], [-3, 3, 0.5, sin(0.2)**2, cos(2*3*0.2...
cc0cc63c848c1f9bf06e9ff0673e6d5d1d89f766 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc0cc63c848c1f9bf06e9ff0673e6d5d1d89f766/test_basic.py
[x,w] = P_roots(n)
[x,w] = p_roots(n)
def fixed_quad(func,a,b,args=(),n=5): """Compute a definite integral using fixed-order Gaussian quadrature. Description: Integrate func from a to b using Gaussian quadrature of order n. Inputs: func -- a Python function or method to integrate. a -- lower limit of integration b -- upper limit of integration args -- ...
58a7ddfe107d57ab71db9e15ec1eb934835ca7e3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/58a7ddfe107d57ab71db9e15ec1eb934835ca7e3/quadrature.py
return (kvp(v-1,z,n-1) - kvp(v+1,z,n-1))/2.0
return (kvp(v-1,z,n-1) + kvp(v+1,z,n-1))/(-2.0)
def kvp(v,z,n=1): """Return the nth derivative of Kv(z) with respect to z. """ if not isinstance(n,types.IntType) or (n<0): raise ValueError, "n must be a non-negative integer." if n == 0: return kv(v,z) else: return (kvp(v-1,z,n-1) - kvp(v+1,z,n-1))/2.0
25fdc9a434d27ad47c3e1b11ae461962bd71e2fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/25fdc9a434d27ad47c3e1b11ae461962bd71e2fe/basic.py
return (ivp(v-1,z,n-1) - ivp(v+1,z,n-1))/2.0
return (ivp(v-1,z,n-1) + ivp(v+1,z,n-1))/2.0
def ivp(v,z,n=1): """Return the nth derivative of Iv(z) with respect to z. """ if not isinstance(n,types.IntType) or (n<0): raise ValueError, "n must be a non-negative integer." if n == 0: return iv(v,z) else: return (ivp(v-1,z,n-1) - ivp(v+1,z,n-1))/2.0
25fdc9a434d27ad47c3e1b11ae461962bd71e2fe /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/25fdc9a434d27ad47c3e1b11ae461962bd71e2fe/basic.py
x0 = asarray(x0)
x0 = asfarray(x0)
def fmin(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0): """Minimize a function using the downhill simplex algorithm. Description: Uses a Nelder-Mead simplex algorithm to find the minimum of function of one or more variables. Inputs: func -- the Python function ...
0998927eeb572b45c05d84192cc1bd490bd9cad1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/0998927eeb572b45c05d84192cc1bd490bd9cad1/optimize.py
extra_args = (func, p, xi) + args
extra_args = (func, p, xi, args)
def _linesearch_powell(func, p, xi, args=(), tol=1e-3): # line-search algorithm using fminbound # find the minimium of the function # func(x0+ alpha*direc) global _powell_funcalls extra_args = (func, p, xi) + args alpha_min, fret, iter, num = brent(_myfunc, args=extra_args, full_output=1, tol=tol) xi = alpha_min*xi _...
0998927eeb572b45c05d84192cc1bd490bd9cad1 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/0998927eeb572b45c05d84192cc1bd490bd9cad1/optimize.py
tc = 1.0/max(abs(vals.real)) T = arange(0,8*tc,8*tc / float(N))
tc = 1.0/max(abs(real(vals))) T = arange(0,10*tc,10*tc / float(N))
def impulse(system, X0=None, T=None, N=None): if isinstance(system, lti): sys = system else: sys = lti(*system) if X0 is None: B = sys.B else: B = sys.B + X0 if N is None: N = 100 if T is None: vals = linalg.eigvals(sys.A) tc = 1.0/max(abs(vals.real)) T = arange(0,8*tc,8*tc / float(N)) h = zeros(T.shape, sys.A.typecode...
268e9b5bffbd8a297de272073e03dd07dffaa5bc /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/268e9b5bffbd8a297de272073e03dd07dffaa5bc/ltisys.py
winfun = bohman
winfunc = bohman
def get_window(window,Nx,fftbins=1): """Return a window of length Nx and type window. If fftbins is 1, create a "periodic" window ready to use with ifftshift and be multiplied by the result of an fft (SEE ALSO fftfreq). Window types: boxcar, triang, blackman, hamming, hanning, bartlett, parzen, bohman, blackmanharri...
6d365e1efe06bcd9acb52e95effa641fc7813fbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6d365e1efe06bcd9acb52e95effa641fc7813fbf/signaltools.py
winfun = nuttall
winfunc = nuttall
def get_window(window,Nx,fftbins=1): """Return a window of length Nx and type window. If fftbins is 1, create a "periodic" window ready to use with ifftshift and be multiplied by the result of an fft (SEE ALSO fftfreq). Window types: boxcar, triang, blackman, hamming, hanning, bartlett, parzen, bohman, blackmanharri...
6d365e1efe06bcd9acb52e95effa641fc7813fbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6d365e1efe06bcd9acb52e95effa641fc7813fbf/signaltools.py
winfu = barthann
winfunc = barthann
def get_window(window,Nx,fftbins=1): """Return a window of length Nx and type window. If fftbins is 1, create a "periodic" window ready to use with ifftshift and be multiplied by the result of an fft (SEE ALSO fftfreq). Window types: boxcar, triang, blackman, hamming, hanning, bartlett, parzen, bohman, blackmanharri...
6d365e1efe06bcd9acb52e95effa641fc7813fbf /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/6d365e1efe06bcd9acb52e95effa641fc7813fbf/signaltools.py
(1000,975):47641862536236518640933948075167736642053976275040L
(1000,975):47641862536236518640933948075167736642053976275040L,
def check_exact(self): resdict = {(10,2):45L, (10,5):252L, (1000,20):339482811302457603895512614793686020778700L, (1000,975):47641862536236518640933948075167736642053976275040L (-10,1):0L, (10,-1):0L, (-10,-3):0L,(10,11),0L} for key in resdict.keys(): assert_equal(comb(key[0],key[1],exact=1),resdict[key])
a13a6ebfbfdb688eadbeb3fdfe185e17515fc763 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/a13a6ebfbfdb688eadbeb3fdfe185e17515fc763/test_common.py
print llx+width+deltax, ypos-deltay
def legend(text,linetypes=None,lleft=None,color='black',tfont='helvetica',fontsize=14,nobox=0): """Construct and place a legend. Description: Build a legend and place it on the current plot with an interactive prompt. Inputs: text -- A list of strings which document the curves. linetypes -- If not given, then the t...
b20fe2f8ff483286a18bc9dfd6b487a064310134 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/b20fe2f8ff483286a18bc9dfd6b487a064310134/Mplot.py
raise RunTimeError, "Infinity comparisons don't work for you."
raise RuntimeError, "Infinity comparisons don't work for you."
def _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points): infbounds = 0 if (b != Inf and a != -Inf): pass # standard integration elif (b == Inf and a != -Inf): infbounds = 1 bound = a elif (b == Inf and a == -Inf): infbounds = 2 bound = 0 # ignored elif (b != Inf and a == -Inf): infbounds = -1 bound = b el...
dec9d9c0137ab47d385ea8be78edc5e5e33bf2b3 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/dec9d9c0137ab47d385ea8be78edc5e5e33bf2b3/quadpack.py
err_type, err_msg = sys.exc_info()[1]
err_type, err_msg = sys.exc_info()[:2]
def _send(self,package,addendum=None): """addendum is either None, or a list of addendums <= in length to the number of workers """ if addendum: N = len(addendum) assert(N <= len(self.workers)) else: N = len(self.workers) self.send_exc = {} self.had_send_error = [] for i in range(N): try: if not addendum: self.workers...
8c750fdeaf19e4ed95953ff790453cca4d7a40d7 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/8c750fdeaf19e4ed95953ff790453cca4d7a40d7/cow.py
from scipy.basic.random import normal
from scipy.random import normal
def get_data(self,x_stride=1,y_stride=1): mult = array(1, dtype = self.dtype) if self.dtype in ['F', 'D']: mult = array(1+1j, dtype = self.dtype) from scipy.basic.random import normal alpha = array(1., dtype = self.dtype) * mult beta = array(1.,dtype = self.dtype) * mult a = normal(0.,1.,(3,3)).astype(self.dtype) * mul...
32ce80164cb0c9e068c7132831c43e7c023b2a7b /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/32ce80164cb0c9e068c7132831c43e7c023b2a7b/test_fblas.py
y = scipy.squeeze(x)
y = _minsqueeze(x)
def plot(x,*args,**keywds): """Plot curves. Description: Plot one or more curves on the same graph. Inputs: There can be a variable number of inputs which consist of pairs or triples. The second variable is plotted against the first using the linetype specified by the optional third variable in the triple. If onl...
3369f4b37045cebc122c3c4201d220da27c6a376 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3369f4b37045cebc122c3c4201d220da27c6a376/Mplot.py
y = scipy.squeeze(y) x = scipy.squeeze(x)
y = _minsqueeze(y) x = _minsqueeze(x)
def plot(x,*args,**keywds): """Plot curves. Description: Plot one or more curves on the same graph. Inputs: There can be a variable number of inputs which consist of pairs or triples. The second variable is plotted against the first using the linetype specified by the optional third variable in the triple. If onl...
3369f4b37045cebc122c3c4201d220da27c6a376 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3369f4b37045cebc122c3c4201d220da27c6a376/Mplot.py
self.image_pixels_per_axis_unit =array(matrix.shape,Float)/axis_lengths
self.image_pixels_per_axis_unit =array((matrix.shape[1], matrix.shape[0]),Float)/axis_lengths
def __init__(self, matrix,x_bounds=None,y_bounds=None,**attr): property_object.__init__(self,attr) if not x_bounds: self.x_bounds = array((0,matrix.shape[1])) else: # works for both 2 element or N element x self.x_bounds = array((x_bounds[0],x_bounds[-1])) if not y_bounds: self.y_bounds = array((0,matrix.shape[0])) els...
5418e2ef7c1d6ad75b66d8f5ac3a7f580289bd32 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5418e2ef7c1d6ad75b66d8f5ac3a7f580289bd32/plot_objects.py
image = wx.wxEmptyImage(self.matrix.shape[0],self.matrix.shape[1])
image = wx.wxEmptyImage(self.matrix.shape[1],self.matrix.shape[0])
def form_image(self): # look up colormap if it si identified by a string if type(self.colormap) == type(''): try: colormap = colormap_map[self.colormap] except KeyError: raise KeyError, 'Invalid colormap name. Choose from %s' \ % `colormap_map.keys()` else: colormap = self.colormap # scale image if we're supposed to. i...
5418e2ef7c1d6ad75b66d8f5ac3a7f580289bd32 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5418e2ef7c1d6ad75b66d8f5ac3a7f580289bd32/plot_objects.py
sz = sz* abs(self.scale) sz = sz.astype(Int) scaled_image = self.the_image.Scale(abs(sz[0]),abs(sz[1]))
sz = sz* self.scale sz = abs(sz.astype(Int)) scaled_image = self.the_image.Scale(sz[0],sz[1])
def draw(self,dc): sz = array((self.the_image.GetWidth(),self.the_image.GetHeight())) sz = sz* abs(self.scale) sz = sz.astype(Int) scaled_image = self.the_image.Scale(abs(sz[0]),abs(sz[1])) bitmap = scaled_image.ConvertToBitmap()
5418e2ef7c1d6ad75b66d8f5ac3a7f580289bd32 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5418e2ef7c1d6ad75b66d8f5ac3a7f580289bd32/plot_objects.py
if self.lower == numpy.NINF: self.lower = -numpy.utils.limits.double_max if self.upper == numpy.PINF: self.upper = numpy.utils.limits.double_max
self.lower = asarray(self.lower) self.lower[self.lower == numpy.NINF] = -_double_max self.upper = asarray(self.upper) self.upper[self.upper == numpy.PINF] = _double_max
def init(self, **options): self.__dict__.update(options) if self.lower == numpy.NINF: self.lower = -numpy.utils.limits.double_max if self.upper == numpy.PINF: self.upper = numpy.utils.limits.double_max self.k = 0 self.accepted = 0 self.feval = 0 self.tests = 0
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
x0 = ones(self.dims,'d') lrange = x0*self.lower urange = x0*self.upper
lrange = self.lower urange = self.upper
def getstart_temp(self, best_state): assert(not self.dims is None) x0 = ones(self.dims,'d') lrange = x0*self.lower urange = x0*self.upper fmax = -300e8 fmin = 300e8 for n in range(self.Ninit): x0[:] = random.uniform(size=self.dims)*(urange-lrange) + lrange fval = self.func(x0,*self.args) self.feval += 1 if fval > fmax:...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
for n in range(self.Ninit): x0[:] = random.uniform(size=self.dims)*(urange-lrange) + lrange fval = self.func(x0,*self.args)
for _ in range(self.Ninit): x0 = random.uniform(size=self.dims)*(urange-lrange) + lrange fval = self.func(x0, *self.args)
def getstart_temp(self, best_state): assert(not self.dims is None) x0 = ones(self.dims,'d') lrange = x0*self.lower urange = x0*self.upper fmax = -300e8 fmin = 300e8 for n in range(self.Ninit): x0[:] = random.uniform(size=self.dims)*(urange-lrange) + lrange fval = self.func(x0,*self.args) self.feval += 1 if fval > fmax:...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
if (p > random.uniform(0.0,1.0)):
if (p > random.uniform(0.0, 1.0)):
def accept_test(self, dE): T = self.T self.tests += 1 if dE < 0: self.accepted += 1 return 1 p = exp(-dE*1.0/self.boltzmann/T) if (p > random.uniform(0.0,1.0)): self.accepted += 1 return 1 return 0
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
self.c = self.m * exp(-self.n * self.quench / self.dims)
self.c = self.m * exp(-self.n * self.quench)
def init(self, **options): self.__dict__.update(options) if self.m is None: self.m = 1.0 if self.n is None: self.n = 1.0 self.c = self.m * exp(-self.n * self.quench / self.dims)
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
u = squeeze(random.uniform(0.0,1.0, size=len(x0)))
u = squeeze(random.uniform(0.0, 1.0, size=self.dims))
def update_guess(self, x0): x0 = asarray(x0) u = squeeze(random.uniform(0.0,1.0, size=len(x0))) T = self.T y = sign(u-0.5)*T*((1+1.0/T)**abs(2*u-1)-1.0) xc = y*(self.upper - self.lower) xnew = x0 + xc return xnew
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
self.T = self.T0*exp(-self.c * self.k**(self.quench/self.dims))
self.T = self.T0*exp(-self.c * self.k**(self.quench))
def update_temp(self): self.T = self.T0*exp(-self.c * self.k**(self.quench/self.dims)) self.k += 1 return
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
numbers = squeeze(random.uniform(-pi/2,pi/2, size=len(x0)))
numbers = squeeze(random.uniform(-pi/2, pi/2, size=self.dims))
def update_guess(self, x0): x0 = asarray(x0) numbers = squeeze(random.uniform(-pi/2,pi/2, size=len(x0))) xc = self.learn_rate * self.T * tan(numbers) xnew = x0 + xc return xnew
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
std = min(sqrt(self.T), (self.upper-self.lower)/3.0/self.learn_rate)
std = minimum(sqrt(self.T)*ones(self.dims), (self.upper-self.lower)/3.0/self.learn_rate)
def update_guess(self, x0): std = min(sqrt(self.T), (self.upper-self.lower)/3.0/self.learn_rate) x0 = asarray(x0) xc = squeeze(random.normal(0,std*self.learn_rate, size=len(x0))) xnew = x0 + xc return xnew
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
xc = squeeze(random.normal(0,std*self.learn_rate, size=len(x0))) xnew = x0 + xc
xc = squeeze(random.normal(0, 1.0, size=self.dims)) xnew = x0 + xc*std*self.learn_rate
def update_guess(self, x0): std = min(sqrt(self.T), (self.upper-self.lower)/3.0/self.learn_rate) x0 = asarray(x0) xc = squeeze(random.normal(0,std*self.learn_rate, size=len(x0))) xnew = x0 + xc return xnew
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
Outputs: (xmin, {Jmin, T, feval, iter, accept,} retval)
Outputs: (xmin, {Jmin, T, feval, iters, accept,} retval)
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
iter -- Number of cooling iterations
iters -- Number of cooling iterations
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
lower = asarray(lower) upper = asarray(upper)
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
schedule.init(dims=len(x0),func=func,args=args,boltzmann=boltzmann,T0=T0,
schedule.init(dims=shape(x0),func=func,args=args,boltzmann=boltzmann,T0=T0,
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
feval = 0 done = 0
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
fqueue = [100,300,500,700] iter=0
fqueue = [100, 300, 500, 700] iters = 0
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
xnew = schedule.update_guess(x0) fval = func(xnew,*args)
current_state.x = schedule.update_guess(last_state.x) current_state.cost = func(current_state.x,*args)
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
current_state.x = asarray(xnew).copy() current_state.cost = fval
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
if dE < 0: last_state.x = current_state.x.copy() last_state.cost = current_state.cost
last_state.x = current_state.x.copy() last_state.cost = current_state.cost
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
iter += 1
iters += 1
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
tmp = fqueue.pop(0)
fqueue.pop(0)
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
print "Warning: Cooled to %f at %f but this is not" \ % (squeeze(last_state.cost), squeeze(last_state.x)) \
print "Warning: Cooled to %f at %s but this is not" \ % (squeeze(last_state.cost), str(squeeze(last_state.x))) \
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
if (iter > maxiter):
if (iters > maxiter):
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
schedule.feval, iter, schedule.accepted, retval
schedule.feval, iters, schedule.accepted, retval
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py
print anneal(func,1.0,full_output=1,upper=3.0,lower=-3.0,feps=1e-4,maxiter=2000,schedule='cauchy') print anneal(func,1.0,full_output=1,upper=3.0,lower=-3.0,feps=1e-4,maxiter=2000,schedule='fast') print anneal(func,1.0,full_output=1,upper=3.0,lower=-3.0,feps=1e-4,maxiter=2000,schedule='boltzmann') func = lambda x: cos...
def anneal(func, x0, args=(), schedule='fast', full_output=0, T0=None, Tf=1e-12, maxeval=None, maxaccept=None, maxiter=400, boltzmann=1.0, learn_rate=0.5, feps=1e-6, quench=1.0, m=1.0, n=1.0, lower=-100, upper=100, dwell=50): """Minimize a function using simulated annealing. Schedule is a schedule class implementing t...
5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5d83f70d8d9b65f40e4932969c9d8113c8f4f8cd/anneal.py