rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
print "di" | def __init__(self, x, y, z, kind='linear', copy=True, bounds_error=False, fill_value=np.nan): """ Initialize a 2D interpolator. | |
print self.x, self.y, self.z | def __init__(self, x, y, z, kind='linear', copy=True, bounds_error=False, fill_value=np.nan): """ Initialize a 2D interpolator. | |
expr = numexpr("2.0*a+3.0*c",[('a',float),('c', float)]) assert_array_equal(expr(a,c), 2.0*a+3.0*c) def check_all_scalar(self): a = 3. b = 4. assert_equal(evaluate("a+b"), a+b) expr = numexpr("2*a+3*b",[('a',float),('b', float)]) assert_equal(expr(a,b), 2*a+3*b) def check_run(self): a = arange(100).reshape(10,10)[::2... | def check_broadcasting(self): a = arange(100).reshape(10,10)[::2] c = arange(10) d = arange(5).reshape(5,1) assert_array_equal(evaluate("a+c"), a+c) assert_array_equal(evaluate("a+d"), a+d) | |
M = amax(new.rowind) + 1 | M = int(amax(new.rowind)) + 1 | def Construct(s, ij=None, M=None ,N=None, nzmax=100, dtype='d', copy=False): """ Allows constructing a csc_matrix by passing: - data, ij, {M,N,nzmax} a[ij[k,0],ij[k,1]] = data[k] - data, (row, ptr) """ # Moved out of the __init__ function for now for simplicity. # I think this should eventually be moved to be a module-... |
new.data = new.data * other | new.data *= other | def __mul__(self, other): # implement matrix multiplication and matrix-vector multiplication if isspmatrix(other): return self.matmat(other) elif isscalar(other): new = self.copy() new.data = new.data * other new._dtypechar = new.data.dtypechar new.ftype = _transtabl[new._dtypechar] return new else: return self.matvec... |
if isinstance(other, type(3)): raise NotImplementedError elif isscalar(other): | if isscalar(other): | def __pow__(self, other): if isinstance(other, type(3)): raise NotImplementedError elif isscalar(other): new = self.copy() new.data = new.data * other new._dtypechar = new.data.dtypechar new.ftype = _transtabl[new._dtypechar] return new else: ocs = csc_matrix(other) if (ocs.shape != self.shape): raise ValueError, "Inco... |
new.data = new.data * other | new.data = new.data ** other | def __pow__(self, other): if isinstance(other, type(3)): raise NotImplementedError elif isscalar(other): new = self.copy() new.data = new.data * other new._dtypechar = new.data.dtypechar new.ftype = _transtabl[new._dtypechar] return new else: ocs = csc_matrix(other) if (ocs.shape != self.shape): raise ValueError, "Inco... |
new = csr_matrix(N,M,nzmax=0,dtype=self._dtypechar) | new = csr_matrix((N,M), nzmax=0, dtype=self._dtypechar) | def transpose(self, copy=False): M,N = self.shape new = csr_matrix(N,M,nzmax=0,dtype=self._dtypechar) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new |
elif isinstance(key,type(3)): | elif type(key) == int: | def __getitem__(self, key): if isinstance(key,types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools,self.ftype+'cscgetel') M, N = self.shape if not (0<=row<M) or not (0<=col<N): raise KeyError, "Index out of bounds." ind, val = func(self.data, self.rowind, self.indptr, row, col) return val elif isinsta... |
M, N = self.shape | def copy(self): M, N = self.shape dtype = self._dtypechar new = csc_matrix.Construct(M, N, nzmax=0, dtype=dtype) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new | |
new = csc_matrix.Construct(M, N, nzmax=0, dtype=dtype) | new = csc_matrix(self.shape, nzmax=0, dtype=dtype) | def copy(self): M, N = self.shape dtype = self._dtypechar new = csc_matrix.Construct(M, N, nzmax=0, dtype=dtype) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new |
N = amax(new.colind) + 1 | N = int(amax(new.colind)) + 1 | def Construct(s, ij=None, M=None ,N=None, nzmax=100, dtype='d', copy=False): """ Allows constructing a csr_matrix by passing: - data, ij, {M,N,nzmax} a[ij[k,0],ij[k,1]] = data[k] - data, (row, ptr) """ # Moved out of the __init__ function for now for simplicity. # I think this should eventually be moved to be a module-... |
if isinstance(other, type(3)): raise NotImplementedError elif isscalar(other): | if isscalar(other): | def __pow__(self, other): if isinstance(other, type(3)): raise NotImplementedError elif isscalar(other): new = self.copy() new.data = new.data * other new._dtypechar = new.data.dtypechar new.ftype = _transtabl[new._dtypechar] return new else: ocs = csr_matrix(other) if (ocs.shape != self.shape): raise ValueError, "Inco... |
new.data = new.data * other | new.data = new.data ** other | def __pow__(self, other): if isinstance(other, type(3)): raise NotImplementedError elif isscalar(other): new = self.copy() new.data = new.data * other new._dtypechar = new.data.dtypechar new.ftype = _transtabl[new._dtypechar] return new else: ocs = csr_matrix(other) if (ocs.shape != self.shape): raise ValueError, "Inco... |
elif isinstance(key,type(3)): | elif type(key) == int: | def __getitem__(self, key): if isinstance(key,types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools,self.ftype+'cscgetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row >= M ) or (col >= N) or (row < 0) or (col < 0): raise IndexError, "Index out of bounds." ind, val ... |
M, N = self.shape new = csr_matrix(M, N, nzmax=0, dtype=self._dtypechar) | new = csr_matrix(self.shape, nzmax=0, dtype=self._dtypechar) | def copy(self): M, N = self.shape new = csr_matrix(M, N, nzmax=0, dtype=self._dtypechar) new.data = self.data.copy() new.colind = self.colind.copy() new.indptr = self.indptr.copy() new._check() return new |
keys = self.keys() | def matvec(self, other): other = asarray(other) if other.shape[0] != self.shape[1]: raise ValueError, "Dimensions do not match." keys = self.keys() res = [0]*self.shape[0] for key in keys: res[int(key[0])] += self[key] * other[int(key[1]),...] return array(res) | |
for key in keys: | for key in self.keys(): | def matvec(self, other): other = asarray(other) if other.shape[0] != self.shape[1]: raise ValueError, "Dimensions do not match." keys = self.keys() res = [0]*self.shape[0] for key in keys: res[int(key[0])] += self[key] * other[int(key[1]),...] return array(res) |
keys = self.keys() | def rmatvec(self, other): other = asarray(other) | |
for key in keys: | for key in self.keys(): | def rmatvec(self, other): other = asarray(other) |
M = amax(ij[0]) | M = int(amax(ij[0])) | def __init__(self, obj, ij, M=None, N=None, nzmax=None, dtype=None): spmatrix.__init__(self) if type(ij) is type(()) and len(ij)==2: if M is None: M = amax(ij[0]) if N is None: N = amax(ij[1]) self.row = asarray(ij[0],'i') self.col = asarray(ij[1],'i') else: aij = asarray(ij,'i') if M is None: M = amax(aij[:,0]) if N i... |
N = amax(ij[1]) | N = int(amax(ij[1])) | def __init__(self, obj, ij, M=None, N=None, nzmax=None, dtype=None): spmatrix.__init__(self) if type(ij) is type(()) and len(ij)==2: if M is None: M = amax(ij[0]) if N is None: N = amax(ij[1]) self.row = asarray(ij[0],'i') self.col = asarray(ij[1],'i') else: aij = asarray(ij,'i') if M is None: M = amax(aij[:,0]) if N i... |
M = amax(aij[:,0]) | M = int(amax(aij[:,0])) | def __init__(self, obj, ij, M=None, N=None, nzmax=None, dtype=None): spmatrix.__init__(self) if type(ij) is type(()) and len(ij)==2: if M is None: M = amax(ij[0]) if N is None: N = amax(ij[1]) self.row = asarray(ij[0],'i') self.col = asarray(ij[1],'i') else: aij = asarray(ij,'i') if M is None: M = amax(aij[:,0]) if N i... |
N = amax(aij[:,1]) | N = int(amax(aij[:,1])) | def __init__(self, obj, ij, M=None, N=None, nzmax=None, dtype=None): spmatrix.__init__(self) if type(ij) is type(()) and len(ij)==2: if M is None: M = amax(ij[0]) if N is None: N = amax(ij[1]) self.row = asarray(ij[0],'i') self.col = asarray(ij[1],'i') else: aij = asarray(ij,'i') if M is None: M = amax(aij[:,0]) if N i... |
edges.update(zip(self.triangle_nodes[border[:,0]][:,1], self.triangle_nodes[border[:,0]][:,2])) edges.update(zip(self.triangle_nodes[border[:,1]][:,2], self.triangle_nodes[border[:,1]][:,0])) edges.update(zip(self.triangle_nodes[border[:,2]][:,0], self.triangle_nodes[border[:,2]][:,1])) | edges.update(dict(zip(self.triangle_nodes[border[:,0]][:,1], self.triangle_nodes[border[:,0]][:,2]))) edges.update(dict(zip(self.triangle_nodes[border[:,1]][:,2], self.triangle_nodes[border[:,1]][:,0]))) edges.update(dict(zip(self.triangle_nodes[border[:,2]][:,0], self.triangle_nodes[border[:,2]][:,1]))) | def _compute_convex_hull(self): """Extract the convex hull from the triangulation information. |
def configuration(parent_package='',parent_path=None): from scipy.distutils.system_info import get_info package = 'cluster' local_path = get_path(__name__,parent_path) config = Configuration(package,parent_package) | def configuration(parent_package='',top_path=None): from scipy.distutils.misc_util import Configuration config = Configuration('cluster',parent_package,top_path) config.add_data_dir('tests') | def configuration(parent_package='',parent_path=None): from scipy.distutils.system_info import get_info package = 'cluster' local_path = get_path(__name__,parent_path) config = Configuration(package,parent_package) config.add_extension('_vq', sources=[join('src', 'vq_wrap.cpp')]) return config |
**configuration() | **configuration(top_path='').todict() | def configuration(parent_package='',parent_path=None): from scipy.distutils.system_info import get_info package = 'cluster' local_path = get_path(__name__,parent_path) config = Configuration(package,parent_package) config.add_extension('_vq', sources=[join('src', 'vq_wrap.cpp')]) return config |
def __init__(self,freq,year=None, month=None, day=None, seconds=None,quarter=None, date=None, val=None): if hasattr(freq,'freq'): | def __init__(self, freq, year=None, month=None, day=None, seconds=None,quarter=None, mxDate=None, val=None): if hasattr(freq, 'freq'): | def __init__(self,freq,year=None, month=None, day=None, seconds=None,quarter=None, date=None, val=None): if hasattr(freq,'freq'): self.freq = corelib.fmtFreq(freq.freq) else: self.freq = corelib.fmtFreq(freq) self.type = corelib.freqToType(self.freq) if val is not None: if self.freq == 'D': self.__date = val+originDa... |
elif date is not None: self.__date = date | elif mxDate is not None: self.__date = mxDate | def __init__(self,freq,year=None, month=None, day=None, seconds=None,quarter=None, date=None, val=None): if hasattr(freq,'freq'): self.freq = corelib.fmtFreq(freq.freq) else: self.freq = corelib.fmtFreq(freq) self.type = corelib.freqToType(self.freq) if val is not None: if self.freq == 'D': self.__date = val+originDa... |
if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") | if self.freq in ("B", "D"): return self.strfmt("%d-%b-%y") | def __str__(self): if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") elif self.freq == "S": return self.__date.strftime("%d-%b-%Y %H:%M:%S") elif self.freq == "M": return self.__date.strftime("%b-%Y") elif self.freq == "Q": return str(self.year())+"q"+str(self.quarter()) elif self.freq == "A": return s... |
return self.__date.strftime("%d-%b-%Y %H:%M:%S") | return self.strfmt("%d-%b-%Y %H:%M:%S") | def __str__(self): if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") elif self.freq == "S": return self.__date.strftime("%d-%b-%Y %H:%M:%S") elif self.freq == "M": return self.__date.strftime("%b-%Y") elif self.freq == "Q": return str(self.year())+"q"+str(self.quarter()) elif self.freq == "A": return s... |
return self.__date.strftime("%b-%Y") | return self.strfmt("%b-%Y") | def __str__(self): if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") elif self.freq == "S": return self.__date.strftime("%d-%b-%Y %H:%M:%S") elif self.freq == "M": return self.__date.strftime("%b-%Y") elif self.freq == "Q": return str(self.year())+"q"+str(self.quarter()) elif self.freq == "A": return s... |
return str(self.year())+"q"+str(self.quarter()) | return self.strfmt("%Yq%q") | def __str__(self): if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") elif self.freq == "S": return self.__date.strftime("%d-%b-%Y %H:%M:%S") elif self.freq == "M": return self.__date.strftime("%b-%Y") elif self.freq == "Q": return str(self.year())+"q"+str(self.quarter()) elif self.freq == "A": return s... |
return str(self.year()) | return self.strfmt("%Y") | def __str__(self): if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") elif self.freq == "S": return self.__date.strftime("%d-%b-%Y %H:%M:%S") elif self.freq == "M": return self.__date.strftime("%b-%Y") elif self.freq == "Q": return str(self.year())+"q"+str(self.quarter()) elif self.freq == "A": return s... |
return self.__date.strftime("%d-%b-%y") | return self.strfmt("%d-%b-%y") | def __str__(self): if self.freq in ("B","D"): return self.__date.strftime("%d-%b-%y") elif self.freq == "S": return self.__date.strftime("%d-%b-%Y %H:%M:%S") elif self.freq == "M": return self.__date.strftime("%b-%Y") elif self.freq == "Q": return str(self.year())+"q"+str(self.quarter()) elif self.freq == "A": return s... |
if self.freq <> other.freq: raise ValueError("Cannont subtract dates of different frequency (" + str(self.freq) + " <> " + str(other.freq) + ")") | if self.freq != other.freq: raise ValueError("Cannont subtract dates of different frequency (" + str(self.freq) + " != " + str(other.freq) + ")") | def __sub__(self, other): try: return self + (-1) * other except: pass try: if self.freq <> other.freq: raise ValueError("Cannont subtract dates of different frequency (" + str(self.freq) + " <> " + str(other.freq) + ")") return int(self) - int(other) except TypeError: raise TypeError("Could not subtract types " + str(... |
if self.freq <> other.freq: | if self.freq != other.freq: | def __eq__(self, other): if self.freq <> other.freq: raise TypeError("frequencies are not equal!") return int(self) == int(other) |
if self.freq <> other.freq: | if self.freq != other.freq: | def __cmp__(self, other): if self.freq <> other.freq: raise TypeError("frequencies are not equal!") return int(self)-int(other) |
return Date(freq, date=tempDate) | return Date(freq, mxDate=tempDate) | def thisday(freq): freq = corelib.fmtFreq(freq) tempDate = mx.DateTime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday if freq == 'B' and tempDate.day_of_week >= 5: tempDate -= (tempDate.day_of_week - 4) if freq == 'B' or freq == 'D' or freq == 'S': return Date(freq, date=tempDate)... |
return Date(freq,tempDate.year,tempDate.month) | return Date(freq, year=tempDate.year, month=tempDate.month) | def thisday(freq): freq = corelib.fmtFreq(freq) tempDate = mx.DateTime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday if freq == 'B' and tempDate.day_of_week >= 5: tempDate -= (tempDate.day_of_week - 4) if freq == 'B' or freq == 'D' or freq == 'S': return Date(freq, date=tempDate)... |
return Date(freq,tempDate.year,quarter=monthToQuarter(tempDate.month)) | return Date(freq, yaer=tempDate.year, quarter=monthToQuarter(tempDate.month)) | def thisday(freq): freq = corelib.fmtFreq(freq) tempDate = mx.DateTime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday if freq == 'B' and tempDate.day_of_week >= 5: tempDate -= (tempDate.day_of_week - 4) if freq == 'B' or freq == 'D' or freq == 'S': return Date(freq, date=tempDate)... |
return Date(freq,tempDate.year) def prevbusday(day_end_hour=18,day_end_min=0): | return Date(freq, year=tempDate.year) def prevbusday(day_end_hour=18, day_end_min=0): | def thisday(freq): freq = corelib.fmtFreq(freq) tempDate = mx.DateTime.now() # if it is Saturday or Sunday currently, freq==B, then we want to use Friday if freq == 'B' and tempDate.day_of_week >= 5: tempDate -= (tempDate.day_of_week - 4) if freq == 'B' or freq == 'D' or freq == 'S': return Date(freq, date=tempDate)... |
def dateOf(_date,_destFreq,_relation="BEFORE"): _destFreq = corelib.fmtFreq(_destFreq) _rel = _relation.upper()[0] if _date.freq == _destFreq: return _date elif _date.freq == 'D': if _destFreq == 'B': tempDate = _date.mxDate() if _rel == "B": | def dateOf(date, toFreq, relation="BEFORE"): toFreq = corelib.fmtFreq(toFreq) _rel = relation.upper()[0] if date.freq == toFreq: return date elif date.freq == 'D': if toFreq == 'B': tempDate = date.mxDate() if _rel == 'B': | def prevbusday(day_end_hour=18,day_end_min=0): tempDate = mx.DateTime.localtime() dateNum = tempDate.hour + float(tempDate.minute)/60 checkNum = day_end_hour + float(day_end_min)/60 if dateNum < checkNum: return thisday('B') - 1 else: return thisday('B') |
'blas_src',blas_src_info['sources'], | 'blas_src',blas_src_info['sources'] + \ [os.path.join(local_path,'src','fblaswrap.f')], | def configuration(parent_package=''): if sys.platform == 'win32': import scipy_distutils.mingw32_support from scipy_distutils.core import Extension from scipy_distutils.misc_util import get_path, default_config_dict from scipy_distutils.misc_util import fortran_library_item, dot_join from scipy_distutils.system_info ... |
sys.args.insert(0,'scipy_core') | sys.argv.insert(0,'scipy_core') | def get_package_config(name): sys.path.insert(0,os.path.join('scipy_core',name)) try: mod = __import__('setup_'+name) config = mod.configuration() finally: del sys.path[0] return config |
from scipy.special import binomcdf, binomcdfc, binomcdfinv, betacdf, betaq, fcdf, \ fcdfc, fp, gammacdf, gammacdfc, gammaq, negbinomcdf, negbinomcdfinv, \ possioncdf, poissioncdfc, possioncdfinv, studentcdf, studentq, \ chi2cdf, chi2cdfc, chi2p, normalcdf, normalq, smirnovcdfc, smirnovp, \ kolmogorovcdfc, kolmogorovp | def friedmanchisquare(*args): """ | |
fcdfc, fp, gammacdf, gammacdfc, gammaq, negbinomcdf, negbinomcdfinv, \ possioncdf, poissioncdfc, possioncdfinv, studentcdf, studentq, \ chi2cdf, chi2cdfc, chi2p, normalcdf, normalq, smirnovcdfc, smirnovp, \ kolmogorovcdfc, kolmogorovp | fcdfc, fp, gammacdf, gammacdfc, gammaq, negbinomcdf, negbinomcdfinv from scipy.special import poissoncdf, poissoncdfc, poissoncdfinv, studentcdf, \ studentq, chi2cdf, chi2cdfc, chi2p, normalcdf, normalq, smirnovcdfc from scipy.special import smirnovp, kolmogorovcdfc, kolmogorovp | def friedmanchisquare(*args): """ |
lin = 1. + b * X | lin = 1 + b*X | def information(self, b, ties='breslow'): |
maxfun=None, full_output=0, disp=1, retall=0, callback=None): | maxfun=None, full_output=0, disp=1, retall=0, callback=None, direc=None): | def fmin_powell(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None): """Minimize a function using modified Powell's method. Description: Uses a modification of Powell's method to find the minimum of a function of N variables Inputs: func -- the Python ... |
direc = eye(N,dtype=float) | if direc is None: direc = eye(N, dtype=float) else: direc = asarray(direc, dtype=float) | def fmin_powell(func, x0, args=(), xtol=1e-4, ftol=1e-4, maxiter=None, maxfun=None, full_output=0, disp=1, retall=0, callback=None): """Minimize a function using modified Powell's method. Description: Uses a modification of Powell's method to find the minimum of a function of N variables Inputs: func -- the Python ... |
print "Gegenbauer, a = ", a | def check_gegenbauer(self): a = 5*rand()-0.5 if any(a==0): a = -0.2 print "Gegenbauer, a = ", a Ca0 = gegenbauer(0,a) Ca1 = gegenbauer(1,a) Ca2 = gegenbauer(2,a) Ca3 = gegenbauer(3,a) Ca4 = gegenbauer(4,a) Ca5 = gegenbauer(5,a) | |
jc = jv(0,.1) assert_almost_equal(jc,0.99750156206604002,8) | values = [[0, 0.1, 0.99750156206604002], [2./3, 1e-8, 0.3239028506761532e-5], [2./3, 1e-10, 0.1503423854873779e-6], [3.1, 1e-10, 0.1711956265409013e-32], [2./3, 4.0, -0.2325440850267039], ] for i, (v, x, y) in enumerate(values): yc = jv(v, x) assert_almost_equal(yc, y, 8, err_msg='test | def check_jv(self): jc = jv(0,.1) assert_almost_equal(jc,0.99750156206604002,8) |
maxnfeval : max. number of function evaluation | maxfun : max. number of function evaluation | def fmin_tnc(func, x0, fprime=None, args=(), approx_grad=False, bounds=None, epsilon=1e-8, scale=None, messages=MSG_ALL, maxCGit=-1, maxfun=None, eta=-1, stepmx=0, accuracy=0, fmin=0, ftol=0, rescale=-1): """Minimize a function with variables subject to bounds, using gradient information. returns (rc, nfeval, x). Inp... |
up[i] = l | up[i] = u | def func_and_grad(x): x = asarray(x) f = func(x, *args) g = fprime(x, *args) return f, list(g) |
rc, nf, x = minimize(function, [-7, 3], bounds=([-10, 10], [1, 10])) | rc, nf, x = fmin_tnc(function, [-7, 3], bounds=([-10, 10], [1, 10])) | def function(x): f = pow(x[0],2.0)+pow(abs(x[1]),3.0) g = [0,0] g[0] = 2.0*x[0] g[1] = 3.0*pow(abs(x[1]),2.0) if x[1]<0: g[1] = -g[1] return f, g |
rc, nf, x = minimize(fg, x, bounds=bounds, messages = MSG_NONE, maxnfeval = 200) | rc, nf, x = fmin_tnc(fg, x, bounds=bounds, messages = MSG_NONE, maxnfeval = 200) | def test(fg, x, bounds, xopt): print "** Test", fg.__name__ rc, nf, x = minimize(fg, x, bounds=bounds, messages = MSG_NONE, maxnfeval = 200) print "After", nf, "function evaluations, TNC returned:", RCSTRINGS[rc] print "x =", x print "exact value =", xopt enorm = 0.0 norm = 1.0 for y,yo in zip(x, xopt): enorm += (y-yo... |
assert isinstance(ij, ArrayType) and (rank(ij) == 2) and (shape(ij) == (len(s), 2)) | assert isinstance(ij, ArrayType) and (rank(ij) == 2) \ and (shape(ij) == (2, len(s))) | def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSC format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: #s = asarr... |
temp = coo_matrix((s, ij), dims=dims, dtype=dtype).tocsc() | ijnew = array(ij, copy=copy) temp = coo_matrix((s, ijnew), dims=dims, \ dtype=self.dtype).tocsc() | def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSC format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: #s = asarr... |
a[ij[k, 0], ij[k, 1]] = data[k] | a[ij[0, k], ij[1, k]] = data[k] | def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new |
assert isinstance(ij, ArrayType) and (rank(ij) == 2) and (shape(ij) == (len(s), 2)) | assert isinstance(ij, ArrayType) and (rank(ij) == 2) \ and (shape(ij) == (2, len(s))) | def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: s = arg1 o... |
except: raise ValueError, "unrecognized form for csr_matrix constructor" | def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: s = arg1 o... | |
ijnew = ij.copy() ijnew[:, 0] = ij[:, 1] ijnew[:, 1] = ij[:, 0] temp = coo_matrix((s, ijnew), dims=dims, dtype=dtype).tocsr() | self.dtype = getdtype(dtype, s) ijnew = array([ij[1], ij[0]], copy=copy) temp = coo_matrix((s, ijnew), dims=dims, \ dtype=self.dtype).tocsr() | def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: s = arg1 o... |
self.dtype = temp.dtype | def __init__(self, arg1, dims=None, nzmax=NZMAX, dtype=None, copy=False): spmatrix.__init__(self) if isdense(arg1): self.dtype = getdtype(dtype, arg1) # Convert the dense array or matrix arg1 to CSR format if rank(arg1) == 1: # Convert to a row vector arg1 = arg1.reshape(1, arg1.shape[0]) if rank(arg1) == 2: s = arg1 o... | |
A = coo_matrix(obj, ij, [dims]) | A = coo_matrix((obj, ij), [dims]) | def resize(self, shape): """ Resize the matrix to dimensions given by 'shape', removing any non-zero elements that lie outside. """ M, N = self.shape try: newM, newN = shape assert newM == int(newM) and newM > 0 assert newN == int(newN) and newN > 0 except (TypeError, ValueError, AssertionError): raise TypeError, "dime... |
ij[:][0] and ij[:][1] | ij[0][:] and ij[1][:] | def resize(self, shape): """ Resize the matrix to dimensions given by 'shape', removing any non-zero elements that lie outside. """ M, N = self.shape try: newM, newN = shape assert newM == int(newM) and newM > 0 assert newN == int(newN) and newN > 0 except (TypeError, ValueError, AssertionError): raise TypeError, "dime... |
1. obj[:]: the entries of the matrix, in any order 2. ij[:][0]: the row indices of the matrix entries 3. ij[:][1]: the column indices of the matrix entries | 1. obj[:] the entries of the matrix, in any order 2. ij[0][:] the row indices of the matrix entries 3. ij[1][:] the column indices of the matrix entries | def resize(self, shape): """ Resize the matrix to dimensions given by 'shape', removing any non-zero elements that lie outside. """ M, N = self.shape try: newM, newN = shape assert newM == int(newM) and newM > 0 assert newN == int(newN) and newN > 0 except (TypeError, ValueError, AssertionError): raise TypeError, "dime... |
A[ij[k][0], ij[k][1]] = obj[k] | A[ij[0][k], ij[1][k] = obj[k] | def resize(self, shape): """ Resize the matrix to dimensions given by 'shape', removing any non-zero elements that lie outside. """ M, N = self.shape try: newM, newN = shape assert newM == int(newM) and newM > 0 assert newN == int(newN) and newN > 0 except (TypeError, ValueError, AssertionError): raise TypeError, "dime... |
obj, ij_in = arg1 | obj, ij = arg1 | def __init__(self, arg1, dims=None, dtype=None): spmatrix.__init__(self) if isinstance(arg1, tuple): try: obj, ij_in = arg1 except: raise TypeError, "invalid input format" elif arg1 is None: # clumsy! We should make ALL arguments # keyword arguments instead! # Initialize an empty matrix. if not isinstance(dims, t... |
if len(ij_in) != 2: if isdense( ij_in ) and (ij_in.shape[1] == 2): ij = (ij_in[:,0], ij_in[:,1]) else: raise AssertionError else: ij = ij_in if dims is None: M = int(amax(ij[0])) + 1 N = int(amax(ij[1])) + 1 self.shape = (M, N) else: M, N = dims self.shape = (M, N) self.row = asarray(ij[0]) self.col = asarray(ij[1]) s... | if len(ij) != 2: raise TypeError except TypeError: | def __init__(self, arg1, dims=None, dtype=None): spmatrix.__init__(self) if isinstance(arg1, tuple): try: obj, ij_in = arg1 except: raise TypeError, "invalid input format" elif arg1 is None: # clumsy! We should make ALL arguments # keyword arguments instead! # Initialize an empty matrix. if not isinstance(dims, t... |
def complex(a, b, complex=__builtins__.complex): c = zeros(a.shape, dtype=complex) | def complex(a, b): c = zeros(a.shape, dtype=complex_) | def complex(a, b, complex=__builtins__.complex): c = zeros(a.shape, dtype=complex) c.real = a c.imag = b return c |
tests.append(('OPERATIONS', optests)) | def complex(a, b, complex=__builtins__.complex): c = zeros(a.shape, dtype=complex) c.real = a c.imag = b return c | |
x = random.randint(1,2**31-1) | x = random.randint(1,2**31-2) | def seed(x=0,y=0): """seed(x, y), set the seed using the integers x, y; Set a random one from clock if y == 0 """ if type (x) != types.IntType or type (y) != types.IntType : raise ArgumentError, "seed requires integer arguments." if y == 0: import random y = int(rv.initial_seed()) x = random.randint(1,2**31-1) rand.se... |
self.isCSR = 1 | self.isCSR = 0 | def _getIndx( self, mtx ): |
self.isCSR = 0 | self.isCSR = 1 | def _getIndx( self, mtx ): |
assert rt == T, 'Expected %s, got %s type' % (T, rt) | assert N.dtype(rt) == N.dtype(T), \ 'Expected %s, got %s type' % (T, rt) | def test_smallest_int_sctype(self): # Smallest int sctype with testing recaster params = sctype_attributes() mmax = params[N.int32]['max'] mmin = params[N.int32]['min'] for kind in ('int', 'uint'): for T in N.sctypes[kind]: mx = params[T]['max'] mn = params[T]['min'] rt = self.recaster.smallest_int_sctype(mx, mn) if mx... |
panel = TestPanel(self) | self.panel = TestPanel(self) | def __init__(self, parent): |
def is_alive(obj): if obj() is None: return 0 else: return 1 | def is_alive(obj): if obj() is None: return 0 else: return 1 | |
time.sleep(0.25) | yield() | def check_wx_class(self): "Checking a wxFrame proxied class" for i in range(5): f = gui_thread.register(TestFrame) a = f(None) p = weakref.ref(a) a.Close(1) del a time.sleep(0.25) # sync threads # this checks for memory leaks self.assertEqual(is_alive(p), 0) |
class NoThreadTestFrame(wxFrame): | class TesterApp (wxApp): def OnInit (self): f = TesterFrame(None) return true class TesterFrame(wxFrame): | def test(): all_tests = test_suite() runner = unittest.TextTestRunner(verbosity=2) runner.run(all_tests) |
wxFrame.__init__(self, parent, -1, "Hello Test") | wxFrame.__init__(self, parent, -1, "Tester") self.CreateStatusBar() sizer = wxBoxSizer(wxHORIZONTAL) ID = NewId() btn = wxButton(self, ID, "Start Test") EVT_BUTTON(self, ID, self.OnStart) msg = "Click to start running tests. "\ "Tester Output will be shown on the shell." btn.SetToolTip(wxToolTip(msg)) sizer.Add(btn, 1... | def __init__(self, parent): wxFrame.__init__(self, parent, -1, "Hello Test") test() self.Close(1) |
app = wxPySimpleApp() frame = NoThreadTestFrame(None) | app = TesterApp() | def __init__(self, parent): wxFrame.__init__(self, parent, -1, "Hello Test") test() self.Close(1) |
'libraries' : ['specfun'] | 'libraries' : ['specfun'], 'depends':specfun | def configuration(parent_package='',parent_path=None): from scipy_distutils.core import Extension from scipy_distutils.misc_util import get_path,\ default_config_dict, dot_join from scipy_distutils.system_info import dict_append, get_info package = 'special' config = default_config_dict(package,parent_package) local_p... |
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 |
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 |
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... |
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... |
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... |
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... |
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... |
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[... |
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[... | |
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 \ |
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) /... |
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) /... |
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) /... |
nzmax = 0 | try: nzmax = self.nnz except AtrributeError: nzmax = 0 | def getnzmax(self): try: nzmax = self.nzmax except AttributeError: nzmax = 0 return nzmax |
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) |
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... |
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... |
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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.