rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
print "Adding a constant:" c += 5 print c | def _testme(): a = csc_matrix((arange(1, 9), numpy.transpose([[0, 1, 1, 2, 2, 3, 3, 4], [0, 1, 3, 0, 2, 3, 4, 4]]))) print "Representation of a matrix:" print repr(a) print "How a matrix prints:" print a print "Adding two matrices:" b = a+a print b print "Subtracting two matrices:" c = b - a print c print "Multiplying ... | |
bprime[j] = val | bprime[j] = real(val) | def bilinear(b,a,fs=1.0): """Return a digital filter from an analog filter using the bilinear transform. The bilinear transform substitutes (z-1) / (z+1) for s """ fs =float(fs) a,b = map(atleast_1d,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = Num.Float M = max([N,D]) Np = M Dp = M bprime = Num.zeros(Np+1,artype) apr... |
aprime[j] = val | aprime[j] = real(val) | def bilinear(b,a,fs=1.0): """Return a digital filter from an analog filter using the bilinear transform. The bilinear transform substitutes (z-1) / (z+1) for s """ fs =float(fs) a,b = map(atleast_1d,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = Num.Float M = max([N,D]) Np = M Dp = M bprime = Num.zeros(Np+1,artype) apr... |
x,y = asarray(x, y) | x = asarray(x) y = asarray(y) | def mannwhitneyu(x,y): """ |
result = squeeze(transpose(reshape(result,dims[::-1]))) | result = squeeze(transpose(reshape(result,tupdims))) | def _parse_mimatrix(fid,bytes): dclass, cmplx, nzmax =_parse_array_flags(fid) dims = _get_element(fid)[0] name = ''.join(asarray(_get_element(fid)[0]).astype('c')) if dclass in mxArrays: result, unused =_get_element(fid) if type == mxCHAR_CLASS: result = ''.join(asarray(result).astype('c')) else: if cmplx: imag, unused... |
y = scipy.stats.linregress(BIG,X) | y = scipy.stats.linregress(X,BIG) | def check_linregressBIGX(self): """ W.II.F. Regress BIG on X. |
lwork = calc_lwork.getri(getri.prefix,a1.shape[0])[1] | lwork = calc_lwork.getri(getri.prefix,a1.shape[0]) lwork = lwork[1] lwork = int(1.01*lwork) | def inv(a, overwrite_a=0): """Return inverse of square matrix a. """ a1 = asarray(a) if len(a1.shape) != 2 or a1.shape[0] != a1.shape[1]: raise ValueError, 'expected square matrix' overwrite_a = overwrite_a or a1 is not a #XXX: I found no advantage or disadvantage of using finv. |
def configuration(parent_package='',parent_path=None): config = Configuration('integrate', parent_package, parent_path) blas_opt = get_info('blas_opt') if not blas_opt: raise NotFoundError,'no blas resources found' | blas_opt = get_info('blas_opt',notfound_action=2) | def configuration(parent_package='',parent_path=None): config = Configuration('integrate', parent_package, parent_path) blas_opt = get_info('blas_opt') if not blas_opt: raise NotFoundError,'no blas resources found' config.add_library('linpack_lite', sources=[join('linpack_lite','*.f')]) config.add_library('mach', sou... |
setup(**configuration(parent_path='')) | setup(**configuration(top_path='').todict()) | def configuration(parent_package='',parent_path=None): config = Configuration('integrate', parent_package, parent_path) blas_opt = get_info('blas_opt') if not blas_opt: raise NotFoundError,'no blas resources found' config.add_library('linpack_lite', sources=[join('linpack_lite','*.f')]) config.add_library('mach', sou... |
libs.extend(blas_opt['libraries']) | if blas_opt.has_key('libraries'): libs.extend(blas_opt['libraries']) | def configuration(parent_package='',parent_path=None): config = Configuration('integrate', parent_package, parent_path) blas_opt = get_info('blas_opt') if not blas_opt: raise NotFoundError,'no blas resources found' config.add_library('linpack_lite', sources=[join('linpack_lite','*.f')]) config.add_library('mach', sou... |
execstring = 'column = map(lambda x: x'+cnums+', listoflists)' exec execstring | evalstring = 'map(lambda x: x'+cnums+', listoflists)' column = eval(evalstring) | def colex (listoflists,cnums): """\nExtracts from listoflists the columns specified in the list 'cnums' (cnums can be an integer, a sequence of integers, or an expression that |
fname = os.path.join(__path__[0],'plt','lena.dat') | fname = os.path.join(os.path.dirname(__file__),'plt','lena.dat') | def lena(): import cPickle, os fname = os.path.join(__path__[0],'plt','lena.dat') f = open(fname,'rb') lena = scipy.array(cPickle.load(f)) f.close() return lena |
assert_equal(cephes.pro_ang1_cv(1,1,1,1,0),(1.0,0.0)) | assert_array_almost_equal(cephes.pro_ang1_cv(1,1,1,1,0), array((1.0,0.0))) | def check_pro_ang1_cv(self): assert_equal(cephes.pro_ang1_cv(1,1,1,1,0),(1.0,0.0)) |
ext = Extension(name="_lbfgsb",sources=sources, **lapack) | ext = Extension(dot_join(parent_package,package,"_lbfgsb"), sources=sources, **lapack) | def configuration(parent_package='',parent_path=None): package = 'optimize' config = default_config_dict(package,parent_package) local_path = get_path(__name__,parent_path) minpack = glob(os.path.join(local_path,'minpack','*.f')) config['fortran_libraries'].append(('minpack',{'sources':minpack})) sources = ['_minpack... |
ext = Extension(name="moduleTNC", sources=sources) | ext = Extension(dot_join(parent_package,package,'moduleTNC'), sources=sources) | def configuration(parent_package='',parent_path=None): package = 'optimize' config = default_config_dict(package,parent_package) local_path = get_path(__name__,parent_path) minpack = glob(os.path.join(local_path,'minpack','*.f')) config['fortran_libraries'].append(('minpack',{'sources':minpack})) sources = ['_minpack... |
width = fac*(x[2]-x[1]) | width = fac*(x[1]-x[0]) | def errorbars(x,y,err,ptcolor='r',linecolor='b',pttype='o',linetype='-',fac=0.25): """Draw connected points with errorbars. Description: Plot connected points with errorbars. Inputs: x, y -- The points to plot. err -- The error in the y values. ptcolor -- The color for the points. linecolor -- The color of the conn... |
print linetypes[k], text[k] print llx+width+deltax, ypos-deltay | def legend(text,linetypes=None,lleft=None,color=None,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 text... | |
config_list += map(get_separate_package_config,separate_packages) config_list += map(get_package_config,scipy_packages) | def setup_package(ignore_packages=[]): old_path = os.getcwd() path = get_path(__name__) os.chdir(path) sys.path.insert(0,os.path.join(path,'Lib')) # setup files of subpackages require scipy_core: sys.path.insert(0,os.path.join(path,'scipy_core')) try: #sys.path.insert(0,os.path.join(path,'Lib')) from scipy_version impo... | |
for i in ["_core_", "_controls_", "_misc_", "_windows_", "_gdi_"]: | for i in [\"_core_\", \"_controls_\", \"_misc_\", \"_windows_\", \"_gdi_\"]: | def _import_wx_core(wx_pth, pexec): """Imports the core modules for wx. This is necessary for wxPython-2.5.x. """ # Find the suffix. suffix = '.so' for x in [x[0] for x in imp.get_suffixes() if x[-1] is imp.C_EXTENSION]: if os.path.exists(os.path.join(wx_pth, '_core_' + x)): suffix = x break # Now import the modules m... |
return 1 | def _import_wx_core(wx_pth, pexec): """Imports the core modules for wx. This is necessary for wxPython-2.5.x. """ # Find the suffix. suffix = '.so' for x in [x[0] for x in imp.get_suffixes() if x[-1] is imp.C_EXTENSION]: if os.path.exists(os.path.join(wx_pth, '_core_' + x)): suffix = x break # Now import the modules m... | |
output = valarray(shape(cond),value=self.a) | output = valarray(shape(cond),value=self.a*scale + loc) | def ppf(self,q,*args,**kwds): loc,scale=map(kwds.get,['loc','scale']) args, loc, scale = self.__fix_loc_scale(args, loc, scale) q,loc,scale = map(arr,(q,loc,scale)) args = tuple(map(arr,args)) cond0 = self._argcheck(*args) & (scale > 0) & (loc==loc) cond1 = (q > 0) & (q < 1) cond2 = (q==1) & cond0 cond = cond0 & cond1 ... |
insert(output,cond2,self.b) | insert(output,cond2,self.b*scale + loc) | def ppf(self,q,*args,**kwds): loc,scale=map(kwds.get,['loc','scale']) args, loc, scale = self.__fix_loc_scale(args, loc, scale) q,loc,scale = map(arr,(q,loc,scale)) args = tuple(map(arr,args)) cond0 = self._argcheck(*args) & (scale > 0) & (loc==loc) cond1 = (q > 0) & (q < 1) cond2 = (q==1) & cond0 cond = cond0 & cond1 ... |
return c/3.0, (1.0-c+c*c)/18, sqrt(2)*(2*c-1)*(c+1)*(c-2) / \ | return (c+1.0)/3.0, (1.0-c+c*c)/18, sqrt(2)*(2*c-1)*(c+1)*(c-2) / \ | def _stats(self, c): return c/3.0, (1.0-c+c*c)/18, sqrt(2)*(2*c-1)*(c+1)*(c-2) / \ (5*(1.0-c+c*c)**1.5), -3.0/5.0 |
if not 'MATHLIB' in os.environ: | if not os.environ.has_key('MATHLIB'): | def config_toplevel(self): print " ============= begin top level configuration =============" |
config['packages'].append(dot_join(parent_package,'stats')) | def configuration(parent_package=''): #if parent_package: # parent_package += '.' local_path = get_path(__name__) test_path = os.path.join(local_path,'tests') config = default_config_dict() #config['packages'].append(dot_join(parent_package,'stats')) config['packages'].append(dot_join(parent_package,'stats.tests'))... | |
R = dot(r, transpose(perm)) | R = dot(r, perm) | def leastsq(func,x0,args=(),Dfun=None,full_output=0,col_deriv=0,ftol=1.49012e-8,xtol=1.49012e-8,gtol=0.0,maxfev=0,epsfcn=0.0,factor=100,diag=None): """Minimize the sum of squares of a set of equations. Description: Return the point which minimizes the sum of squares of M (non-linear) equations in N unknowns given a s... |
def check_gradient(fcn,Dfcn,x0,col_deriv=0): | def check_gradient(fcn,Dfcn,x0,args=(),col_deriv=0): | def check_gradient(fcn,Dfcn,x0,col_deriv=0): """Perform a simple check on the gradient for correctness. """ x = atleast_1d(x0) n = len(x) x.shape = (n,) fvec = atleast_1d(fcn(x)) if 1 not in fvec.shape: raise ValueError, "Function does not return a 1-D array." m = len(fvec) fvec.shape = (m,) ldfjac = m fjac = atleast_... |
fvec = atleast_1d(fcn(x)) if 1 not in fvec.shape: raise ValueError, "Function does not return a 1-D array." | fvec = atleast_1d(fcn(x,*args)) | def check_gradient(fcn,Dfcn,x0,col_deriv=0): """Perform a simple check on the gradient for correctness. """ x = atleast_1d(x0) n = len(x) x.shape = (n,) fvec = atleast_1d(fcn(x)) if 1 not in fvec.shape: raise ValueError, "Function does not return a 1-D array." m = len(fvec) fvec.shape = (m,) ldfjac = m fjac = atleast_... |
fjac = atleast_1d(Dfcn(x)) | fjac = atleast_1d(Dfcn(x,*args)) | def check_gradient(fcn,Dfcn,x0,col_deriv=0): """Perform a simple check on the gradient for correctness. """ x = atleast_1d(x0) n = len(x) x.shape = (n,) fvec = atleast_1d(fcn(x)) if 1 not in fvec.shape: raise ValueError, "Function does not return a 1-D array." m = len(fvec) fvec.shape = (m,) ldfjac = m fjac = atleast_... |
fvecp = atleast_1d(fcn(xp)) | fvecp = atleast_1d(fcn(xp,*args)) | def check_gradient(fcn,Dfcn,x0,col_deriv=0): """Perform a simple check on the gradient for correctness. """ x = atleast_1d(x0) n = len(x) x.shape = (n,) fvec = atleast_1d(fcn(x)) if 1 not in fvec.shape: raise ValueError, "Function does not return a 1-D array." m = len(fvec) fvec.shape = (m,) ldfjac = m fjac = atleast_... |
include_dirs = [numpy.get_numpy_include()], sources = [join('src',f) for f in ['_intsamplermodule.c', 'sampler5tbl.c']] ) | include_dirs = [numpy.get_numpy_include(), '/usr/include/python2.4/numpy/random/'], libraries=['randomkit'], sources = [join('src', f) for f in ['_intsamplermodule.c', 'compact5table.c']] ) | def configuration(parent_package='', top_path=None): config = Configuration('montecarlo', parent_package, top_path) config.add_extension('_intsampler', include_dirs = [numpy.get_numpy_include()], sources = [join('src',f) for f in ['_intsamplermodule.c', 'sampler5tbl.c']] ) config.add_data_dir('tests') config.add_dat... |
assert_equal(cephes.nrdtrimn(0.5,1,1),1.0) | assert_approx_equal(cephes.nrdtrimn(0.5,1,1),1.0) | def check_nrdtrimn(self): assert_equal(cephes.nrdtrimn(0.5,1,1),1.0) |
-7.940178689168587]),11) | -7.940178689168587]),10) | def check_bei_zeros(self): bi = bi_zeros(5) assert_array_almost_equal(bi[0],array([-1.173713222709127, -3.271093302836352, -4.830737841662016, -6.169852128310251, -7.376762079367764]),11) |
assert_almost_equal(w,0.90047299861907959,7) assert_almost_equal(pw,0.042089745402336121,7) | assert_almost_equal(w,0.90047299861907959,6) assert_almost_equal(pw,0.042089745402336121,6) | def check_basic(self): x1 = [0.11,7.87,4.61,10.14,7.95,3.14,0.46, 4.43,0.21,4.75,0.71,1.52,3.24, 0.93,0.42,4.97,9.53,4.55,0.47,6.66] w,pw = scipy.stats.shapiro(x1) assert_almost_equal(w,0.90047299861907959,7) assert_almost_equal(pw,0.042089745402336121,7) x2 = [1.36,1.14,2.92,2.55,1.46,1.06,5.27,-1.11, 3.48,1.10,0.88,-... |
assert_almost_equal(w,0.9590269923210144,7) assert_almost_equal(pw,0.52459925413131714,7) | assert_almost_equal(w,0.9590269923210144,6) assert_almost_equal(pw,0.52459925413131714,6) | def check_basic(self): x1 = [0.11,7.87,4.61,10.14,7.95,3.14,0.46, 4.43,0.21,4.75,0.71,1.52,3.24, 0.93,0.42,4.97,9.53,4.55,0.47,6.66] w,pw = scipy.stats.shapiro(x1) assert_almost_equal(w,0.90047299861907959,7) assert_almost_equal(pw,0.042089745402336121,7) x2 = [1.36,1.14,2.92,2.55,1.46,1.06,5.27,-1.11, 3.48,1.10,0.88,-... |
xk += update | xk = xk + update | def fmin_ncg(f, x0, fprime, fhess_p=None, fhess=None, args=(), avextol=1e-5, epsilon=_epsilon, maxiter=None, full_output=0, disp=1, retall=0, callback=None): """Description: Minimize the function, f, whose gradient is given by fprime using the Newton-CG method. fhess_p must compute the hessian times an arbitrary vect... |
assert_equal(cephes.cbrt(1),1.0) | assert_approx_equal(cephes.cbrt(1),1.0) | def check_cbrt(self): assert_equal(cephes.cbrt(1),1.0) |
assert_equal(cephes.exp10(2),100.0) | assert_approx_equal(cephes.exp10(2),100.0) | def check_exp10(self): assert_equal(cephes.exp10(2),100.0) |
assert_equal(cb,cbrl) | assert_approx_equal(cb,cbrl) | def check_cbrt(self): cb = cbrt(27) cbrl = 27**(1.0/3.0) assert_equal(cb,cbrl) |
assert_equal(ex,exrl) | assert_approx_equal(ex,exrl) | def check_exp10(self): ex = exp10(2) exrl = 10**2 assert_equal(ex,exrl) |
if type(x) <> StringType: | if type(x) != StringType: | def makestr (x): if type(x) <> StringType: x = str(x) return x |
if sterr: | if stderr: | def collapse (a,keepcols,collapsecols,stderr=0,ns=0,cfcn=None): """Averages data in collapsecol, keeping all unique items in keepcols (using unique, which keeps unique LISTS of column numbers), retaining the unique sets of values in keepcols, the mean for each. If the sterr or N of the mean are desired, set either or ... |
item.append(stats.sterr(avgcol)) | item.append(stats.stderr(avgcol)) | def collapse (a,keepcols,collapsecols,stderr=0,ns=0,cfcn=None): """Averages data in collapsecol, keeping all unique items in keepcols (using unique, which keeps unique LISTS of column numbers), retaining the unique sets of values in keepcols, the mean for each. If the sterr or N of the mean are desired, set either or ... |
if type(item) <> StringType: | if type(item) != StringType: | def makestr (item): if type(item) <> StringType: item = str(item) return item |
if type(inlist[i]) <> StringType: | if type(inlist[i]) != StringType: | def lineincustcols (inlist,colsizes): """\nReturns a string composed of elements in inlist, with each element |
return string.join(stringlist) | return "".join(stringlist) | def list2string (inlist): """\nConverts a 1D list to a single long string for file output, using |
from scipy_distutils.mingw32_support import * | import scipy_distutils.mingw32_support | def configuration(parent_package=''): if sys.platform == 'win32': from scipy_distutils.mingw32_support import * 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.syste... |
def legend(text,linetypes=None,lleft=None,color='black',tfont='helvetica',fontsize=14,nobox=0): | def legend(text,linetypes=None,lleft=None,color=None,tfont='helvetica',fontsize=14,nobox=0): | 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... |
def _get_namespace(self): return self.__namespace or default_namespace | def _get_namespace(self): if isinstance(self.__namespace, N.ndarray): return self.__namespace else: return self.__namespace or default_namespace | def _get_namespace(self): return self.__namespace or default_namespace |
n = Numeric.searchsorted(Numeric.sort(a), bins) n = Numeric.concatenate([ n, [len(a)]]) | n = searchsorted(sort(a), bins) n = concatenate([ n, [len(a)]]) | def histogram2(a, bins): """ histogram2(a,bins) -- Compute histogram of a using divisions in bins Description: Count the number of times values from array a fall into numerical ranges defined by bins. Range x is given by bins[x] <= range_x < bins[x+1] where x =0,N and N is the length of the bins array. The last rang... |
noise = Numeric.mean(Numeric.ravel(lVar)) | noise = mean(Numeric.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... |
from scipy.stats import mean | def resample(x,num,t=None,axis=0,window=None): """Resample to num samples using Fourier method along the given axis. The resampled signal starts at the same value of x but is sampled with a spacing of len(x) / num * (spacing of x). Because a Fourier method is used, the signal is assumed periodic. Window controls a F... | |
try: from scipy.sandbox.numexpr import expressions modname = 'scipy.sandbox.numexpr.expressions' except ImportError: from numexpr import expressions modname = 'numexpr.expressions' | modname = modname[__name__.rfind('.')-1:] + '.expressions' | def makeExpressions(context): """Make private copy of the expressions module with a custom get_context(). An attempt was made to make this threadsafe, but I can't guarantee it's bulletproof. """ import sys, imp try: from scipy.sandbox.numexpr import expressions modname = 'scipy.sandbox.numexpr.expressions' except Impo... |
class dictsampler(object): | class dictsampler(genericsampler): | def sample(self, size, return_probs=0): """Generates a sample of the given size from the specified discrete distribution, optionally returning the probabilities under the distribution. |
raise TypeError, "unsupported type for adding to a sparse matrix" | raise TypeError, "unsupported type for sparse matrix addition" | def __radd__(self, other): """ Function supporting the operation: self + other. This does not currently work correctly for self + dense. Perhaps dense matrices need some hooks to support this. """ if isscalar(other) or (isdense(other) and rank(other)==0): raise NotImplementedError, 'adding a scalar to a CSC matrix is '... |
raise TypeError, "unknown type for sparse matrix addition" | raise TypeError, "unsupported type for sparse matrix addition" | def __add__(self, other): if isscalar(other) or (isdense(other) and rank(other)==0): raise NotImplementedError, 'adding a scalar to a CSC matrix is ' \ 'not yet supported' elif isspmatrix(other): ocs = other.tocsc() if (ocs.shape != self.shape): raise ValueError, "inconsistent shapes" dtypechar = _coerce_rules[(self.dt... |
raise TypeError, "unsupported type for adding to a sparse matrix" | raise TypeError, "unsupported type for sparse matrix addition" | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): # Now we would add this scalar to every element. raise NotImplementedError, 'adding a scalar to a sparse matrix ' \ 'is not yet supported' elif isspmatrix(other): ocs = other.tocsr() if (ocs.shape ... |
self.shape = (M, N) | assert M == int(M) and M > 0 assert N == int(N) and N > 0 self.shape = (int(M), int(N)) | def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... |
except (TypeError, ValueError): pass | except (TypeError, ValueError, AssertionError): raise TypeError, "dimensions must be a 2-tuple of positive"\ " integers" | def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... |
N = len(values) for n in range(N): self[n, n+k] = values[n] | M, N = self.shape m = len(values) for i in range(min(M, N-k)): self[i, i+k] = values[i] | def setdiag(self, values, k=0): N = len(values) for n in range(N): self[n, n+k] = values[n] return |
if not (exists('src/randomkit.c') and exists('src/randomkit.h')): raise OSError, "Please copy or symlink randomkit.c and randomkit.h to montecarlo/src/ from numpy/random/mtrand/ in the NumPy source tree!" | def configuration(parent_package='', top_path=None): config = Configuration('montecarlo', parent_package, top_path) # This code requires 'randomkit.c' and 'randomkit.h' to have been copied # to (or symlinked to) montecarlo/src/. config.add_extension('_intsampler', sources = [join('src', f) for f in ['_intsamplermodu... | |
from scipy_test.testing import ScipyTest | from scipy.test.testing import ScipyTest | def __init__(self,name,location,p_frame=None): |
from scipy_test.testing import ScipyTest | from scipy.test.testing import ScipyTest | def _ppimport_importer(self): name = self.__name__ |
finished = threading.Event() evt = gui_thread_guts.proxy_event(event_catcher.Close, (),{},finished) event_poster.post(evt) finished.wait() | if in_proxy_call: event_catcher.Close() else: finished = threading.Event() evt = gui_thread_guts.proxy_event(event_catcher.Close, (),{},finished) event_poster.post(evt) finished.wait() | def exit_gui_thread(last_exit = oldexitfunc): # don't wait on MS platforms -- it hangs. # On X11, we have to shut down the secondary thread. if running_in_second_thread and os.name != 'nt': import gui_thread_guts event_poster = gui_thread_guts.proxy_base() event_catcher = event_poster.catcher finished = threading.Event... |
if not hasattr(wx_class, 'init2'): wx_class.init2 = wx_class.__init__ | if not hasattr(wx_class, '_iNiT2'): if hasattr(wx_class, '__init__'): wx_class._iNiT2 = wx_class.__init__ else: wx_class._iNiT2 = None | def register(wx_class): """ Create a gui_thread compatible version of wx_class Test whether a proxy is necessary. If so, generate and return the proxy class. if not, just return the wx_class unaltered. """ if running_in_second_thread: #print 'proxy generated' return proxify(wx_class) else: if not hasattr(wx_class, '... |
self.init2(*args,**kw) | if self._iNiT2: self._iNiT2(*args,**kw) | def plain_class__init__(self,*args,**kw): self.init2(*args,**kw) add_close_event_handler(self) self.proxy_object_alive = 1 |
results = 'self.wx_obj = finished._result;' \ | results = 'self.wx_obj = ret_val;' \ | def generate_method(method,wx_class): """ Create a proxy method. This first creates a text version of the method, accounting for slight differences between __init__ methods and all other methods. It converts the text to a code object (using exec) and returns the code object. The code is never actually written to a f... |
results = 'return smart_return(finished._result, self)' | results = 'return smart_return(ret_val)' | def generate_method(method,wx_class): """ Create a proxy method. This first creates a text version of the method, accounting for slight differences between __init__ methods and all other methods. It converts the text to a code object (using exec) and returns the code object. The code is never actually written to a f... |
%(import_statement)s finished = threading.Event() | %(import_statement)s | body = """def %(method)s(self,*args,**kw): \"\"\"%(documentation)s\"\"\" %(pre_test)s from gui_thread_guts import proxy_event, smart_return %(import_statement)s #import statement finished = threading.Event() # remove proxies if present args = dereference_arglist(args) %(arguments)s #arguments evt = proxy_event(%(call_m... |
%(arguments)s evt = proxy_event(%(call_method)s,arg_list,kw,finished) self.post(evt) finished.wait() if finished.exception_info: raise finished.exception_info[0],finished.exception_info[1] | %(arguments)s ret_val = None if in_proxy_call: ret_val = apply(%(call_method)s, arg_list, kw) else: finished = threading.Event() evt = proxy_event(%(call_method)s,arg_list,kw,finished) self.post(evt) finished.wait() if finished.exception_info: raise finished.exception_info[0], \ finished.exception_info[1] ret_val = fin... | body = """def %(method)s(self,*args,**kw): \"\"\"%(documentation)s\"\"\" %(pre_test)s from gui_thread_guts import proxy_event, smart_return %(import_statement)s #import statement finished = threading.Event() # remove proxies if present args = dereference_arglist(args) %(arguments)s #arguments evt = proxy_event(%(call_m... |
return hasattr(x, '_proxy_attr__proxy') | hasattr(x, 'x._proxy_attr__dont_mess_with_me_unless_you_know_what_youre_doing') | def is_proxy_attr(x): return hasattr(x, '_proxy_attr__proxy') |
return self._cdf(k,*args) - self._cdf(k-1,*args) | return self.cdf(k,*args) - self.cdf(k-1,*args) | def _pdf(self, k, *args): return self._cdf(k,*args) - self._cdf(k-1,*args) |
def logL(self, b, Y, **extra): | def logL(self, b, Y): | def logL(self, b, Y, **extra): return -scipy.linalg.norm(self.whiten(Y) - N.dot(self.wdesign, b))**2 / 2. |
def __init__(self, design, **keywords): LikelihoodModel.__init__(self, **keywords) | def __init__(self, design): LikelihoodModel.__init__(self) | def __init__(self, design, **keywords): LikelihoodModel.__init__(self, **keywords) self.initialize(design) |
def initialize(self, design, **keywords): | def initialize(self, design): | def initialize(self, design, **keywords): self.design = design self.wdesign = self.whiten(design) self.calc_beta = L.pinv(self.wdesign) self.normalized_cov_beta = N.dot(self.calc_beta, N.transpose(self.calc_beta)) self.df_resid = self.wdesign.shape[0] - utils.rank(self.design) |
def fit(self, Y, **keywords): | def fit(self, Y): | def fit(self, Y, **keywords): """ Full \'fit\' of the model including estimate of covariance matrix, (whitened) residuals and scale. |
def __init__(self, design, rho=0, **keywords): LikelihoodModel.__init__(self, **keywords) | def __init__(self, design, rho=0): | def __init__(self, design, rho=0, **keywords): LikelihoodModel.__init__(self, **keywords) self.rho = rho self.initialize(design) |
self.initialize(design) | ols_model.__init__(self, design) | def __init__(self, design, rho=0, **keywords): LikelihoodModel.__init__(self, **keywords) self.rho = rho self.initialize(design) |
class wls_model(ar_model): | class wls_model(ols_model): | def whiten(self, X): factor = 1. / N.sqrt(1 - self.rho**2) return N.concatenate([[X[0]], (X[1:] - self.rho * X[0:-1]) * factor]) |
def __init__(self, design, weights=1, **keywords): LikelihoodModel.__init__(self, **keywords) | def __init__(self, design, weights=1): | def __init__(self, design, weights=1, **keywords): LikelihoodModel.__init__(self, **keywords) self.weights = weights self.initialize(design) |
self.initialize(design) | ols_model.__init__(self, design) | def __init__(self, design, weights=1, **keywords): LikelihoodModel.__init__(self, **keywords) self.weights = weights self.initialize(design) |
norm_resid = self.resid * N.multiply.outer(N.ones(self.Y.shape[0]), sdd) return norm_resid | return self.resid * N.multiply.outer(N.ones(self.Y.shape[0]), sdd) | def norm_resid(self): """ Residuals, normalized to have unit length. |
range = abs(upper - lower) if range == 0.: | rng = abs(upper - lower) if rng == 0.: | def auto_ticks(data_bounds, bounds_info = default_bounds): """ Find locations for axis tick marks. Calculate the location for tick marks on an axis. data_bounds is a sequence of 2 numbers specifying the maximum and minimum values of the data along this axis. bounds_info is a sequence of 3 values that specify how the a... |
if is_base2(range) and is_base2(upper) and range > 4: if range == 2: | if is_base2(rng) and is_base2(upper) and rng > 4: if rng == 2: | def auto_ticks(data_bounds, bounds_info = default_bounds): """ Find locations for axis tick marks. Calculate the location for tick marks on an axis. data_bounds is a sequence of 2 numbers specifying the maximum and minimum values of the data along this axis. bounds_info is a sequence of 3 values that specify how the a... |
elif range == 4: | elif rng == 4: | def auto_ticks(data_bounds, bounds_info = default_bounds): """ Find locations for axis tick marks. Calculate the location for tick marks on an axis. data_bounds is a sequence of 2 numbers specifying the maximum and minimum values of the data along this axis. bounds_info is a sequence of 3 values that specify how the a... |
interval = range / 4 | interval = rng / 4 | def auto_ticks(data_bounds, bounds_info = default_bounds): """ Find locations for axis tick marks. Calculate the location for tick marks on an axis. data_bounds is a sequence of 2 numbers specifying the maximum and minimum values of the data along this axis. bounds_info is a sequence of 3 values that specify how the a... |
hi_ticks = arange(0,auto_upper+interval,interval) low_ticks = - arange(interval,-auto_lower+interval,interval) | hi_ticks = arange(0,upper+interval,interval) low_ticks = - arange(interval,-lower+interval,interval) | def auto_ticks(data_bounds, bounds_info = default_bounds): """ Find locations for axis tick marks. Calculate the location for tick marks on an axis. data_bounds is a sequence of 2 numbers specifying the maximum and minimum values of the data along this axis. bounds_info is a sequence of 3 values that specify how the a... |
ticks = arange(auto_lower,auto_upper+interval,interval) | ticks = arange(lower,upper+interval,interval) | def auto_ticks(data_bounds, bounds_info = default_bounds): """ Find locations for axis tick marks. Calculate the location for tick marks on an axis. data_bounds is a sequence of 2 numbers specifying the maximum and minimum values of the data along this axis. bounds_info is a sequence of 3 values that specify how the a... |
if len(probs) == 1: | if not isscalar(probs) and len(probs) == 1: | def ttest_ind (a, b, axis=0, printit=False, name1='Samp1', name2='Samp2',writemode='a'): """ |
raise ValueError, 'Unequal length arrays.' | raise ValueError, 'unequal length arrays' | def ttest_rel (a,b,axis=None,printit=False,name1='Samp1',name2='Samp2',writemode='a'): """ |
if len(probs) == 1: | if not isscalar(probs) and len(probs) == 1: | def ttest_rel (a,b,axis=None,printit=False,name1='Samp1',name2='Samp2',writemode='a'): """ |
def _drv_pdf(self, xk, *args): | def _drv_pmf(self, xk, *args): | def _drv_pdf(self, xk, *args): try: return self.P[xk] except KeyError: return 0.0 |
ext = Extension(parent_package+'integrate._quadpack',sources) | ext = Extension(parent_package+'integrate._quadpack',sources, library_dirs=atlas_library_dirs, libraries=['quadpack','linpack_lite'] + blas_libraries) | def configuration(parent_package=''): if parent_package: parent_package += '.' local_path = get_path(__name__) config = default_config_dict() if parent_package: config['packages'].append(parent_package+'integrate') #config['packages'].append(parent_package+'integrate.tests') quadpack = glob(os.path.join(local_path,'q... |
blas_libraries, lapack_libraries, atlas_library_dirs = get_atlas_info() | def configuration(parent_package=''): if parent_package: parent_package += '.' local_path = get_path(__name__) config = default_config_dict() if parent_package: config['packages'].append(parent_package+'integrate') #config['packages'].append(parent_package+'integrate.tests') quadpack = glob(os.path.join(local_path,'q... | |
libraries=['odepack','linpack_lite',] + blas_libraries) | libraries=['odepack','linpack_lite'] + blas_libraries) | def configuration(parent_package=''): if parent_package: parent_package += '.' local_path = get_path(__name__) config = default_config_dict() if parent_package: config['packages'].append(parent_package+'integrate') #config['packages'].append(parent_package+'integrate.tests') quadpack = glob(os.path.join(local_path,'q... |
assert_equal(numstring,array([0.,0.1,0.2,0.3, | assert_almost_equal(numstring,array([0.,0.1,0.2,0.3, | def check_arange(self): numstring = arange(0,2.21,.1) assert_equal(numstring,array([0.,0.1,0.2,0.3, 0.4,0.5,0.6,0.7, 0.8,0.9,1.,1.1, 1.2,1.3,1.4,1.5, 1.6,1.7,1.8,1.9, 2.,2.1,2.2])) numstringa = arange(3,4,.3) assert_array_equal(numstringa, array([3.,3.3,3.6,3.9])) numstringb = arange(3,27,3) assert_array_equal(numstrin... |
assert_equal(lag2.c,array([1,-2*(k+2),(k+1.)*(k+2.)])/2.0) assert_equal(lag3.c,array([-1,3*(k+3),-3*(k+2)*(k+3),(k+1)*(k+2)*(k+3)])/6.0) | assert_almost_equal(lag2.c,array([1,-2*(k+2),(k+1.)*(k+2.)])/2.0) assert_almost_equal(lag3.c,array([-1,3*(k+3),-3*(k+2)*(k+3),(k+1)*(k+2)*(k+3)])/6.0) | def check_genlaguerre(self): k = 5*rand()-0.9 lag0 = genlaguerre(0,k) lag1 = genlaguerre(1,k) lag2 = genlaguerre(2,k) lag3 = genlaguerre(3,k) assert_equal(lag0.c,[1]) assert_equal(lag1.c,[-1,k+1]) assert_equal(lag2.c,array([1,-2*(k+2),(k+1.)*(k+2.)])/2.0) assert_equal(lag3.c,array([-1,3*(k+3),-3*(k+2)*(k+3),(k+1)*(k+2)... |
assert_equal(leg3.c,array([5,0,-3,0])/2.0) assert_equal(leg4.c,array([35,0,-30,0,3])/8.0) assert_equal(leg5.c,array([63,0,-70,0,15,0])/8.0) | assert_almost_equal(leg3.c,array([5,0,-3,0])/2.0) assert_almost_equal(leg4.c,array([35,0,-30,0,3])/8.0) assert_almost_equal(leg5.c,array([63,0,-70,0,15,0])/8.0) | def check_legendre(self): leg0 = legendre(0) leg1 = legendre(1) leg2 = legendre(2) leg3 = legendre(3) leg4 = legendre(4) leg5 = legendre(5) assert_equal(leg0.c,[1]) assert_equal(leg1.c,[1,0]) assert_equal(leg2.c,array([3,0,-1])/2.0) assert_equal(leg3.c,array([5,0,-3,0])/2.0) assert_equal(leg4.c,array([35,0,-30,0,3])/8.... |
axis('equal') | try: axis('equal') except AttributeError: _active.client.layout_all() axis('equal') | def image(img,x=None,y=None,colormap = 'grey',scale='no'): """Colormap should really default to the current colormap...""" # check for hold here validate_active() image = wxplt.image_object(img,x,y,colormap=colormap,scale=scale) if not _active.hold in ['on','yes']: _active.line_list.data = [] # clear it out _active.ima... |
assert_array_almost_equal(dot(a,v[:,i]),w[i]*v[:,i]) | assert_array_almost_equal(dot(a,v[:,i]),w[i]*v[:,i],self.decimal) | def check_heev_complex(self,level=1,suffix=''): a= [[1,2-2j,3+7j],[2+2j,2,3],[3-7j,3,5]] exact_w=[-6.305141710654834,2.797880950890922,11.50726075976392] f = getattr(self.lapack,'heev'+suffix) w,v,info=f(a) assert not info,`info` assert_array_almost_equal(w,exact_w) for i in range(3): assert_array_almost_equal(dot(a,v[... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.