rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
q = arr(where(left*(q==q), 1-q, q)) | q = arr(where(left+q-q, 1-q, q)) | def weibullppf(q, shape, left=0, loc=0.0, scale=1.0): a, b, loc, q, left = map(arr,(shape, scale, loc, q, left)) cond1 = (a>0) & (b>0) & (0<=q) & (q<=1) q = arr(where(left*(q==q), 1-q, q)) vals = pow(arr(log(1.0/arr(1-q))),1.0/a) return select([1-cond1,left==0], [scipy.nan, b*vals+loc], -b*vals+loc) |
if (N%2 != 0): raise ValueError, "Length of sequence must be even." xtilde = 0.0*x | even = (N%2 == 0) | def dct(x,axis=-1): n = len(x.shape) N = x.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." xtilde = 0.0*x slices = [None]*4 for k in range(4): slices[k] = [] for j in range(n): slices[k].append(slice(None)) slices[0][axis] = slice(None,N/2) slices[1][axis] = slice(None,None,2) slices[2][... |
slices[k].append(slice(None)) slices[0][axis] = slice(None,N/2) slices[1][axis] = slice(None,None,2) slices[2][axis] = slice(N/2,None) slices[3][axis] = slice(N,None,-2) | slices[k].append(slice(None)) if even: xtilde = 0.0*x slices[0][axis] = slice(None,N/2) slices[1][axis] = slice(None,None,2) slices[2][axis] = slice(N/2,None) slices[3][axis] = slice(N,None,-2) else: newshape = list(x.shape) newshape[axis] = 2*N xtilde = sb.empty(newshape,sb.Float) slices[0][axis] = slice(None,N) slice... | def dct(x,axis=-1): n = len(x.shape) N = x.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." xtilde = 0.0*x slices = [None]*4 for k in range(4): slices[k] = [] for j in range(n): slices[k].append(slice(None)) slices[0][axis] = slice(None,N/2) slices[1][axis] = slice(None,None,2) slices[2][... |
pk = exp(-1j*pi*arange(N)/(2*N)) newshape = ones(n) | pk = sb.exp(-1j*pi*sb.arange(N)/(2*N)) newshape = sb.ones(n) | def dct(x,axis=-1): n = len(x.shape) N = x.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." xtilde = 0.0*x slices = [None]*4 for k in range(4): slices[k] = [] for j in range(n): slices[k].append(slice(None)) slices[0][axis] = slice(None,N/2) slices[1][axis] = slice(None,None,2) slices[2][... |
return squeeze(real(Xt*pk)) | if not even: pk /= 2; Xt = Xt[slices[0]] return sb.real(Xt*pk) | def dct(x,axis=-1): n = len(x.shape) N = x.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." xtilde = 0.0*x slices = [None]*4 for k in range(4): slices[k] = [] for j in range(n): slices[k].append(slice(None)) slices[0][axis] = slice(None,N/2) slices[1][axis] = slice(None,None,2) slices[2][... |
N = v.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." k = arange(N) ak = sb.r_[1.0,[2]*(N-1)]*exp(1j*pi*k/(2*N)) newshape = ones(n) newshape[axis] = N ak.shape = newshape xhat = real(scipy.ifft(v*ak,axis=axis)) x = 0.0*v | N = v.shape[axis] even = (N%2 == 0) | def idct(v,axis=-1): n = len(v.shape) N = v.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." k = arange(N) ak = sb.r_[1.0,[2]*(N-1)]*exp(1j*pi*k/(2*N)) newshape = ones(n) newshape[axis] = N ak.shape = newshape xhat = real(scipy.ifft(v*ak,axis=axis)) x = 0.0*v slices = [None]*4 for k in ra... |
slices[k].append(slice(None)) slices[0][axis] = slice(None,None,2) slices[1][axis] = slice(None,N/2) slices[2][axis] = slice(N,None,-2) slices[3][axis] = slice(N/2,None) for k in range(4): slices[k] = tuple(slices[k]) x[slices[0]] = xhat[slices[1]] x[slices[2]] = xhat[slices[3]] return x | slices[k].append(slice(None)) k = arange(N) if even: ak = sb.r_[1.0,[2]*(N-1)]*exp(1j*pi*k/(2*N)) newshape = ones(n) newshape[axis] = N ak.shape = newshape xhat = real(scipy.ifft(v*ak,axis=axis)) x = 0.0*v slices[0][axis] = slice(None,None,2) slices[1][axis] = slice(None,N/2) slices[2][axis] = slice(N,None,-2) slices[3... | def idct(v,axis=-1): n = len(v.shape) N = v.shape[axis] if (N%2 != 0): raise ValueError, "Length of sequence must be even." k = arange(N) ak = sb.r_[1.0,[2]*(N-1)]*exp(1j*pi*k/(2*N)) newshape = ones(n) newshape[axis] = N ak.shape = newshape xhat = real(scipy.ifft(v*ak,axis=axis)) x = 0.0*v slices = [None]*4 for k in ra... |
def yield(): | def Yield(): | def yield(): if not threaded(): # forces the event handlers to finish their work. # this also forces deletion of windows. wxYield() else: time.sleep(0.05) # sync threads |
yield() | 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 yield() # this checks for memory leaks self.assertEqual(is_alive(p), 0) |
yield() | Yield() | def check_exception(self): "Checking exception handling" f = gui_thread.register(TestFrame) a = f(None) p = weakref.ref(a) self.assertRaises(TypeError, a.Close, 1, 2, 3) a.Close() del a yield() # this checks for memory leaks self.assertEqual(is_alive(p), 0) |
y = x | y = scipy.squeeze(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... |
z = norm(size=self._size) | z = norm.rvs(size=self._size) | def _rvs(self, c): z = norm(size=self._size) U = random(size=self._size) fac = 2 + c*c*z*z det = sqrt(fac*fac - 4) t1 = fac + det t2 = fac - det return t1*(U>0.5) + t2*(U<0.5) |
return abs(norm(mu=c,size=self._size)) | return abs(norm.rvs(mu=c,size=self._size)) | def _rvs(self, c): return abs(norm(mu=c,size=self._size)) |
return abs(norm(size=self._size)) | return abs(norm.rvs(size=self._size)) | def _rvs(self): return abs(norm(size=self._size)) |
return exp(s * norm(size=self._size)) | return exp(s * norm.rvs(size=self._size)) | def _rvs(self, s): return exp(s * norm(size=self._size)) |
M,rest = divmod(header[0],1000) | M,rest = divmod(int(header[0]),1000) | def loadmat(name, dict=None, appendmat=1, basename='raw'): """Load the MATLAB(tm) mat file. If name is a full path name load it in. Otherwise search for the file on the sys.path list and load the first one found (the current directory is searched first). Both v4 (Level 1.0) and v6 matfiles are supported. Version 7.... |
if cfcn = None: | if cfcn is None: | 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 ... |
def figure(n=None, style='/tmp/currstyle.gs', color=-2, frame=0, labelsize=14, labelfont='helvetica',aspect=1.618,dpi=75): | def setdpi(num): """ Set the dpi for new windows """ if num in [75,100]: _dpi = num gist.set_default_dpi(_dpi) else: raise ValueError, "DPI must be 75 or 100" def figure(n=None,style='/tmp/currstyle.gs', color=-2, frame=0, labelsize=14, labelfont='helvetica',aspect=1.618): global _figures | def figure(n=None, style='/tmp/currstyle.gs', color=-2, frame=0, labelsize=14, labelfont='helvetica',aspect=1.618,dpi=75): if (aspect < 0.1) or (aspect > 10): aspect = 1.618 if isinstance(color, types.StringType): color = _colornum[color] fid = open(style,'w') syst = write_style.getsys(color=color,frame=frame, labelsiz... |
gist.window(style=style,width=int(width*1.25/inches*dpi),height=int(height*1.4/inches*dpi),dpi=dpi) else: gist.window(n,style=style,width=int(width*1.25/inches*dpi),height=int(height*1.4/inches*dpi),dpi=dpi) _current_style = style | winnum = gist.window(style=style,width=int(width*1.25/inches*_dpi),height=int(height*1.4/inches*_dpi)) if winnum < 0: gist.window(style=style,width=int(width*1.25/inches*_dpi),height=int(height*1.4/inches*_dpi)) else: gist.window(n,style=style,width=int(width*1.25/inches*_dpi),height=int(height*1.4/inches*_dpi)) _curre... | def figure(n=None, style='/tmp/currstyle.gs', color=-2, frame=0, labelsize=14, labelfont='helvetica',aspect=1.618,dpi=75): if (aspect < 0.1) or (aspect > 10): aspect = 1.618 if isinstance(color, types.StringType): color = _colornum[color] fid = open(style,'w') syst = write_style.getsys(color=color,frame=frame, labelsiz... |
def full_page(win,dpi=75): gist.window(win,style=_current_style,width=int(dpi*8.5),height=dpi*11,dpi=dpi) | def full_page(win): gist.window(win,style=_current_style,width=int(_dpi*8.5),height=_dpi*11) | def full_page(win,dpi=75): gist.window(win,style=_current_style,width=int(dpi*8.5),height=dpi*11,dpi=dpi) |
def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,ticks=1): | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
if dpi != 100: dpi = 75 | if _dpi != 100: | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
conv = inches *1.0 / dpi | conv = inches *1.0 / _dpi | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
maxw = 11*dpi maxh = 8.5*dpi if ph > (8.5*dpi) and pw < (8.5*dpi): | maxw = 11*_dpi maxh = 8.5*_dpi if ph > (8.5*_dpi) and pw < (8.5*_dpi): | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
maxh = 11*dpi maxw = 8.5*dpi | maxh = 11*_dpi maxw = 8.5*_dpi | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
cntr = array([5.5,4.25])*dpi else: cntr = array([4.25,6.75])*dpi | cntr = array([5.5,4.25])*_dpi else: cntr = array([4.25,6.75])*_dpi | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
gist.window(win,style=_current_style,width=int(pw),height=int(ph),dpi=100) | gist.window(win,style=_current_style,width=int(pw),height=int(ph)) | def subplot(Numy,Numx,win=0,pw=None,ph=None,hsep=100,vsep=100,color='black',frame=0,fontsize=8,font=None,dpi=100,ticks=1): # Use gist.plsys to change coordinate systems # all inputs (except fontsize) given as pixels, gist wants # things in normalized device # coordinate. Window is brought up with center of window a... |
q=scipy.split(a,len(self.workers)) herd.cluster.loop_code(name+'=_q_','_q_',inputs={'_q_':q},returns=(),global_vars=(name,)) def row_rather(self,name): | import scipy q=scipy.split(sequence,len(self.workers)) self.loop_code(name+'=_q_','_q_',inputs={'_q_':q},returns=(),global_vars=(name,)) def row_gather(self,name): | def row_split(self,name,sequence): """experimental""" q=scipy.split(a,len(self.workers)) herd.cluster.loop_code(name+'=_q_','_q_',inputs={'_q_':q},returns=(),global_vars=(name,)) |
concatenate(herd.cluster.[name]) | from Numeric import concatenate return concatenate(self[name]) | def row_rather(self,name): """experimental""" concatenate(herd.cluster.[name]) |
elif p<81: | elif p<35: | def daub(p): """The coefficients for the FIR low-pass filter producing Daubechies wavelets. p>=1 gives the order of the zero at f=1/2. There are 2p filter coefficients. """ sqrt = sb.sqrt assert(p>=1) if p==1: c = 1/sqrt(2) return sb.array([c,c]) elif p==2: f = sqrt(2)/8 c = sqrt(3) return f*sb.array([1+c,3+c,3-c,1-c... |
else: raise ValueError, "Cannot factor such large polynomial well." k = sb.r_[0:p] P = s.comb(p-1+k,k)/4.0**k | else: P = [s.comb(p-1+k,k,exact=1)/4.0**k for k in range(p)][::-1] | def daub(p): """The coefficients for the FIR low-pass filter producing Daubechies wavelets. p>=1 gives the order of the zero at f=1/2. There are 2p filter coefficients. """ sqrt = sb.sqrt assert(p>=1) if p==1: c = 1/sqrt(2) return sb.array([c,c]) elif p==2: f = sqrt(2)/8 c = sqrt(3) return f*sb.array([1+c,3+c,3-c,1-c... |
ext_args['macros'] = [('ATLAS_INFO',atlas_version)] | ext_args['define_macros'] = [('ATLAS_INFO',atlas_version)] | def configuration(parent_package=''): from scipy_distutils.core import Extension from scipy_distutils.misc_util import fortran_library_item, dot_join,\ SourceGenerator, get_path, default_config_dict, get_build_temp from scipy_distutils.system_info import get_info,dict_append,\ AtlasNotFoundError,LapackNotFoundError,Bla... |
ext_args['macros'] = [('NO_ATLAS_INFO',1)] | ext_args['define_macros'] = [('NO_ATLAS_INFO',1)] | def configuration(parent_package=''): from scipy_distutils.core import Extension from scipy_distutils.misc_util import fortran_library_item, dot_join,\ SourceGenerator, get_path, default_config_dict, get_build_temp from scipy_distutils.system_info import get_info,dict_append,\ AtlasNotFoundError,LapackNotFoundError,Bla... |
f.write('\ndef get_info(name): return globals().get(name,{})\n') | f.write('\ndef get_info(name): g=globals(); return g.get(name,g.get(name+"_info",{}))\n') | f.write('\ndef get_info(name): return globals().get(name,{})\n') |
self.obj = scipy.ppresolve(obj) | self.obj = obj | def __init__(self, parent, obj, **kw): self.parent = parent self.obj = scipy.ppresolve(obj) self.name = kw.pop('name',None) if self.name is None: self.name = self.obj.__name__ self.canedit = kw.pop('canedit',1) rend.Page.__init__(self, **kw) |
if name not in self.all: | if name not in self.all and not hasattr(self.obj,name): | def childFactory(self, context, name): if name not in self.all: print "Err 1: ", name, self.all return None child = getattr(self.obj,name,None) |
basic_inv = linalg.inverse | basic_inv = linalg.inv | def bench_random(self,level=5): import numpy.linalg as linalg basic_inv = linalg.inverse print print ' Finding matrix inverse' print ' ==================================' print ' | contiguous | non-contiguous ' print '----------------------------------------------' print ' size | scipy | ... |
if 'X11BASE' in os.environ: X11BASE=os.environ['X11BASE'] else: X11BASE="/no/suggested/x11dir" | X11BASE=os.environ.get('X11BASE','/no/suggested/x11dir') | def config_x11(self): print print " ============= begin play/x11 configuration ==============" print from string import replace self.fatality=0 |
libraries = ['X11'] | libraries = x11_info.get('libraries','X11') | def getallparams(gistpath,local): if windows: extra_compile_args = ['-DGISTPATH="\\"' + gistpath + '\\""' ] else: extra_compile_args = ['-DGISTPATH="' + gistpath + '"' ] extra_link_args = [] if windows or cygwin: extra_compile_args.append("-DWINDOWS") extra_compile_args.append("-mwindows") extra_link_args.append("-mwi... |
try: import scipy_distutils except ImportError: extra_packages.append('scipy_distutils') sys.argv.insert(0,'scipy_core') | sys.path.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 |
def ramp(x, y): | def xramp(x, y): | def ramp(x, y): return x |
ramp.title = 'Ramp' | xramp.title = 'X Ramp' def yramp(x, y): return y yramp.title = 'Y Ramp' | def ramp(x, y): return x |
self.inputs = B.shape[-1] self.outputs = C.shape[0] | self.inputs = self.B.shape[-1] self.outputs = self.C.shape[0] | def __init__(self,*args,**kwords): """Initialize the LTI system using either: (numerator, denominator) (zeros, poles, gain) (A, B, C, D) -- state-space. """ N = len(args) if N == 2: # Numerator denominator transfer function input self.__dict__['num'], self.__dict__['den'] = normalize(*args) self.__dict__['zeros'], sel... |
fact = (1-exp(-lamba_)) | fact = (1-exp(-lambda_)) | def _pmf(self, k, lambda_): fact = (1-exp(-lamba_)) return fact*exp(-lambda_(k)) |
y = scipy.stats.stdev(X) | y = scipy.stats.std(X) | def check_stdX(self): y = scipy.stats.stdev(X) assert_almost_equal(y,2.738612788) |
y = scipy.stats.stdev(ZERO) | y = scipy.stats.std(ZERO) | def check_stdZERO(self): y = scipy.stats.stdev(ZERO) assert_almost_equal(y,0.0) |
y = scipy.stats.stdev(BIG) | y = scipy.stats.std(BIG) | def check_stdBIG(self): y = scipy.stats.stdev(BIG) assert_almost_equal(y,2.738612788) |
y = scipy.stats.stdev(LITTLE) | y = scipy.stats.std(LITTLE) | def check_stdLITTLE(self): y = scipy.stats.stdev(LITTLE) assert_approx_equal(y,2.738612788e-8) |
y = scipy.stats.stdev(HUGE) | y = scipy.stats.std(HUGE) | def check_stdHUGE(self): y = scipy.stats.stdev(HUGE) assert_approx_equal(y,2.738612788e12) |
y = scipy.stats.stdev(TINY) | y = scipy.stats.std(TINY) | def check_stdTINY(self): y = scipy.stats.stdev(TINY) assert_almost_equal(y,0.0) |
y = scipy.stats.stdev(ROUND) | y = scipy.stats.std(ROUND) | def check_stdROUND(self): y = scipy.stats.stdev(ROUND) assert_approx_equal(y,2.738612788) |
import fnmatch from fnmatch | from fnmatch import fnmatch | def rmdir(dir,depth=0): import os path = os.path.abspath(dir) all_files = os.listdir(path) indent = ' ' * depth for i in all_files: if not i == 'CVS': print indent, i if os.path.isdir(os.path.join(path,i)): rmdir(os.path.join(path,i),depth+1) else: cmd = 'cd ' + path + ';rm -r ' + i + ';cvs rm ' + i + ';cd ..' print ... |
19391512145,2404879675441, 370371188237525,69348874393137901, 15514534163557086905] | 19391512145l,2404879675441l, 370371188237525l,69348874393137901l, 15514534163557086905l] | def check_euler(self): eu0 = euler(0) eu1 = euler(1) eu2 = euler(2) # just checking segfaults assert_almost_equal(eu0[0],1,8) assert_almost_equal(eu2[2],-1,8) eu24 = euler(24) mathworld = [1,1,5,61,1385,50521,2702765,199360981, 19391512145,2404879675441, 370371188237525,69348874393137901, 15514534163557086905] correc... |
self.vecfunc = new.instancemethod(sgf(self._ppf_single_call), self, rv_continuous) | self.vecfunc = sgf(self._ppf_single_call) self.vecentropy = sgf(self._entropy) | 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 = new.instancemethod(sgf(self._mom0_sc), self, rv_continuous) | self.generic_moment = sgf(self._mom0_sc) | 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 = new.instancemethod(sgf(self._mom1_sc), self, rv_continuous) | self.generic_moment = sgf(self._mom1_sc) | 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... |
def _ppf_tosolve(self, x, q, *args): return apply(self.cdf, (x, )+args) - q | def _ppf_tosolve(self, x, q, *args): return apply(self.cdf, (x, )+args) - q | |
return scipy.optimize.brentq(self._ppf_tosolve, self.xa, self.xb, args=(q,)+args, xtol=self.xtol) | return scipy.optimize.brentq(self._ppf_to_solve, self.xa, self.xb, args=(q,)+args, xtol=self.xtol) | def _ppf_single_call(self, q, *args): return scipy.optimize.brentq(self._ppf_tosolve, self.xa, self.xb, args=(q,)+args, xtol=self.xtol) |
kstwobign = kstwobign_gen(a=0.0,name='kstwobign', longname='Kolmogorov-Smirnov two-sided large N statistic', extradoc=""" Kolmogorov-Smirnov two-sided large N stiatistics | kstwobign = kstwobign_gen(a=0.0,name='kstwobign', longname='Kolmogorov-Smirnov two-sided (for large N)', extradoc=""" Kolmogorov-Smirnov two-sided test for large N | def _ppf(self,q): return special.kolmogi(1.0-q) |
def _entropy(self, c): k = log(1+c) return k/2.0 - log(c/k) | def _stats(self, c, moments='mv'): k = log(1.0+c) mu = (c-k)/(c*k) mu2 = ((c+2.0)*k-2.0*c)/(2*c*k*k) g1 = None g2 = None if 's' in moments: g1 = sqrt(2)*(12*c*c-9*c*k*(c+2)+2*k*k*(c*(c+3)+3)) g1 /= sqrt(c*(c*(k-2)+2*k))*(3*c*(k-2)+6*k) if 'k' in moments: g2 = c**3*(k-3)*(k*(3*k-16)+24)+12*k*c*c*(k-4)*(k-3) \ + 6*c*k*k*... | |
def _stats(self, x, c): return burr_gen._stats(self, x, c, 1.0) | def _stats(self, c): return burr_gen._stats(self, c, 1.0) def _entropy(self, c): return 2 - log(c) | def _stats(self, x, c): return burr_gen._stats(self, x, c, 1.0) |
def _isf(self, q, dfn, dfd): return special.fdtri(dfn, dfd, q) | def _isf(self, q, dfn, dfd): return special.fdtri(dfn, dfd, q) | |
return self._isf(1.0-q, dfn, dfd) | return special.fdtri(dfn, dfd, q) | def _ppf(self, q, dfn, dfd): return self._isf(1.0-q, dfn, dfd) |
self.a = where(c > 0, 0.0, -scipy.inf) | def _argcheck(self, c): c = arr(c) self.b = where(c < 0, 1.0/abs(c), scipy.inf) self.a = where(c > 0, 0.0, -scipy.inf) return where(c==0, 0, 1) | |
genpareto = genpareto_gen(name='genpareto', | def _entropy(self, c): if (c > 0): return 1+c else: self.b = -1.0 / c return rv_continuous._entropy(self, c) genpareto = genpareto_gen(a=0.0,name='genpareto', | def _munp(self, n, c): k = arange(0,n+1) val = (-1.0/c)**n * sum(scipy.comb(n,k)*(-1)**k / (1.0-c*k)) return where(c*n < 1, val, scipy.inf) |
invweibull = invweibull_gen(name='invweibull', | def _entropy(self, c): return 1+_EULER + _EULER / c - log(c) invweibull = invweibull_gen(a=0,name='invweibull', | def _ppf(self, q, c): return pow(-log(q),arr(-1.0/c)) |
return 0, pi*pi/3.0, 0, 6.0/5.0 | return 0, pi*pi/3.0, 0, 6.0/5.0 def _entropy(self): return 1.0 | def _stats(self): return 0, pi*pi/3.0, 0, 6.0/5.0 |
def _stats(self, x): | def _stats(self): | def _stats(self, x): return 0, 0.25, 0, -1.0 |
return 0, None, 0, None | mu2 = 2*gam(lam+1.5)-lam*pow(4,-lam)*sqrt(pi)*gam(lam)*(1-2*lam) mu2 /= lam*lam*(1+2*lam)*gam(1+1.5) mu4 = 3*gam(lam)*gam(lam+0.5)*pow(2,-2*lam) / lam**3 / gam(2*lam+1.5) mu4 += 2.0/lam**4 / (1+4*lam) mu4 -= 2*sqrt(3)*gam(lam)*pow(2,-6*lam)*pow(3,3*lam) * \ gam(lam+1.0/3)*gam(lam+2.0/3) / (lam**3.0 * gam(2*lam+1.5) * \... | def _stats(self, lam): return 0, None, 0, None |
xp = extract( x<pi,x) xn = extract( x>=pi,x) | c1 = x<pi c2 = 1-c1 xp = extract( c1,x) valp = extract(c1,val) xn = extract( c2,x) valn = extract(c2,val) | def _cdf(self, x, c): output = 0.0*x val = (1.0+c)/(1.0-c) xp = extract( x<pi,x) xn = extract( x>=pi,x) if (any(xn)): xn = 2*pi - xn yn = tan(xn/2.0) on = 1.0-1.0/pi*arctan(val*yn) insert(output, x>=pi, on) if (any(xp)): yp = tan(xp/2.0) op = 1.0/pi*arctan(val*yp) insert(output, x<pi, op) return output |
on = 1.0-1.0/pi*arctan(val*yn) insert(output, x>=pi, on) | on = 1.0-1.0/pi*arctan(valn*yn) insert(output, c2, on) | def _cdf(self, x, c): output = 0.0*x val = (1.0+c)/(1.0-c) xp = extract( x<pi,x) xn = extract( x>=pi,x) if (any(xn)): xn = 2*pi - xn yn = tan(xn/2.0) on = 1.0-1.0/pi*arctan(val*yn) insert(output, x>=pi, on) if (any(xp)): yp = tan(xp/2.0) op = 1.0/pi*arctan(val*yp) insert(output, x<pi, op) return output |
op = 1.0/pi*arctan(val*yp) insert(output, x<pi, op) return output | op = 1.0/pi*arctan(valp*yp) insert(output, c1, op) return output def _ppf(self, q, c): val = (1.0-c)/(1.0+c) rcq = 2*arctan(val*tan(pi*q)) rcmq = 2*pi-2*arctan(val*tan(pi*(1-q))) return where(q < 1.0/2, rcq, rcmq) def _entropy(self, c): return log(2*pi*(1-c*c)) | def _cdf(self, x, c): output = 0.0*x val = (1.0+c)/(1.0-c) xp = extract( x<pi,x) xn = extract( x>=pi,x) if (any(xn)): xn = 2*pi - xn yn = tan(xn/2.0) on = 1.0-1.0/pi*arctan(val*yn) insert(output, x>=pi, on) if (any(xp)): yp = tan(xp/2.0) op = 1.0/pi*arctan(val*yp) insert(output, x<pi, op) return output |
raise ValueError | def __call__(self, *args, **kwds): raise ValueError return self.freeze(*args,**kwds) | |
binom = binom_gen(a=0,name='binom',shapes="n,pr",extradoc=""" | def _entropy(self, n, pr): k = r_[0:n+1] vals = self._pmf(k,n,pr) lvals = where(vals==0,0.0,log(vals)) return -sum(vals*lvals) binom = binom_gen(name='binom',shapes="n,pr",extradoc=""" | def _stats(self, n, pr): q = 1.0-pr mu = n * pr var = n * pr * q g1 = (q-pr) / sqrt(n*pr*q) g2 = (1.0-6*pr*q)/(n*pr*q) return mu, var, g1, g2 |
bernoulli = bernoulli_gen(a=0,b=1,name='bernoulli',shapes="pr",extradoc=""" | def _entropy(self, pr): return -pr*log(pr)-(1-pr)*log(1-pr) bernoulli = bernoulli_gen(b=1,name='bernoulli',shapes="pr",extradoc=""" | def _stats(self, pr): return binom_gen._stats(self, 1, pr) |
self.a = n | def _argcheck(self, n, pr): self.a = n return (n >= 0) & (pr >= 0) & (pr <= 1) | |
poisson = poisson_gen(a=0,name="poisson", longname='A Poisson', | poisson = poisson_gen(name="poisson", longname='A Poisson', | def _stats(self, mu): var = mu g1 = 1.0/arr(sqrt(mu)) g2 = 1.0 / arr(mu) return mu, var, g1, g2 |
dlaplace = dlaplace_gen(a=1,name='dlaplace', longname='A discrete Laplacian', | def _entropy(self, a): return a / sinh(a) - log(tanh(a/2.0)) dlaplace = dlaplace_gen(a=-scipy.inf, name='dlaplace', longname='A discrete Laplacian', | def _stats(self, a): ea = exp(-a) e2a = exp(-2*a) e3a = exp(-3*a) e4a = exp(-4*a) mu2 = 2* (e2a + ea) / (1-ea)**3.0 mu4 = 2* (e4a + 11*e3a + 11*e2a + ea) / (1-ea)**5.0 return 0.0, mu2, 0.0, mu4 / mu2**2.0 - 3 |
A = ones((Npts,2),'d') A[:,0] = arange(1,Npts+1)*1.0/Npts | A = ones((Npts,2),dtype) A[:,0] = cast[dtype](arange(1,Npts+1)*1.0/Npts) | def detrend(data, axis=-1, type='linear', bp=0): """Remove linear trend along axis from data. If type is 'constant' then remove mean only. If bp is given, then it is a sequence of points at which to break a piecewise-linear fit to the data. """ if type not in ['linear','l','constant','c']: raise ValueError, "Trend ty... |
" .astype(), or set sparse.useUmfpack = False" | " .astype(), or set linsolve.useUmfpack = False" | def spsolve(A, b, permc_spec=2): if not hasattr(A, 'tocsr') and not hasattr(A, 'tocsc'): raise ValueError, "sparse matrix must be able to return CSC format--"\ "A.tocsc()--or CSR format--A.tocsr()" if not hasattr(A, 'shape'): raise ValueError, "sparse matrix must be able to return shape" \ " (rows, cols) = A.shape" M, ... |
eps = scipy.limits.epsilon('d') | eps = scipy_base.limits.double_epsilon | def _stats(self): return 0.5, 1.0/12, 0, -1.2 |
def configuration(parent_package='', parent_path=None): local_path = get_path(__name__) config = Configuration('delaunay', parent_package, parent_path) | def configuration(parent_package='', top_path=None): config = Configuration('delaunay', parent_package, top_path) | def configuration(parent_package='', parent_path=None): local_path = get_path(__name__) config = Configuration('delaunay', parent_package, parent_path) config.add_extension("_delaunay", sources=["_delaunay.cpp", "VoronoiDiagramGenerator.cpp", "delaunay_utils.cpp", "natneighbors.cpp"], include_dirs=[local_path], ) ret... |
include_dirs=[local_path], | include_dirs=['.'], | def configuration(parent_package='', parent_path=None): local_path = get_path(__name__) config = Configuration('delaunay', parent_package, parent_path) config.add_extension("_delaunay", sources=["_delaunay.cpp", "VoronoiDiagramGenerator.cpp", "delaunay_utils.cpp", "natneighbors.cpp"], include_dirs=[local_path], ) ret... |
svsp = m.spacesaver() | svsp = getattr(m,'spacesaver',lambda:0)() | def tril(m, k=0): """ returns the elements on and below the k-th diagonal of m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main diagonal. """ svsp = m.spacesaver() m = asarray(m,savespace=1) out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m out.savespace(svsp) return out |
svsp = m.spacesaver() | svsp = getattr(m,'spacesaver',lambda:0)() | def triu(m, k=0): """ returns the elements on and above the k-th diagonal of m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main diagonal. """ svsp = m.spacesaver() m = asarray(m,savespace=1) out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m out.savespace(svsp) return out |
func -- a Python function or method to integrate. | func -- a Python function or method to integrate (must accept vector inputs) | 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 -- ... |
newval = fixed_quad(func,a,b,args,n)[0] | newval = fixed_quad(vec_func,a,b,(func,)+args,n)[0] | def quadrature(func,a,b,args=(),tol=1.49e-8,maxiter=50): """Compute a definite integral using fixed-tolerance Gaussian quadrature. Description: Integrate func from a to b using Gaussian quadrature with absolute tolerance tol. Inputs: func -- a Python function or method to integrate. a -- lower limit of integration.... |
from scipy_distutils.misc_util import fortran_library_item, dot_join,\ SourceGenerator, get_path, default_config_dict, get_build_temp from scipy_distutils.system_info import get_info,dict_append,\ AtlasNotFoundError,LapackNotFoundError,BlasNotFoundError,\ LapackSrcNotFoundError,BlasSrcNotFoundError,NotFoundError | from scipy_distutils.misc_util import dot_join, get_path, default_config_dict from scipy_distutils.system_info import get_info, dict_append, NotFoundError | def configuration(parent_package='',parent_path=None): from scipy_distutils.core import Extension from scipy_distutils.misc_util import fortran_library_item, dot_join,\ SourceGenerator, get_path, default_config_dict, get_build_temp from scipy_distutils.system_info import get_info,dict_append,\ AtlasNotFoundError,Lapack... |
'generic_fblas3.pyf']) | 'generic_fblas3.pyf', 'interface_gen.py']) | def generate_pyf(extension, build_dir): name = extension.name.split('.')[-1] target = join(build_dir,target_dir,name+'.pyf') if name[0]=='c' and atlas_version is None and newer(__file__,target): f = open(target,'w') f.write('python module '+name+'\n') f.write('usercode void empty_module(void) {}\n') f.write('interface\... |
'generic_cblas1.pyf']) | 'generic_cblas1.pyf', 'interface_gen.py']) | def generate_pyf(extension, build_dir): name = extension.name.split('.')[-1] target = join(build_dir,target_dir,name+'.pyf') if name[0]=='c' and atlas_version is None and newer(__file__,target): f = open(target,'w') f.write('python module '+name+'\n') f.write('usercode void empty_module(void) {}\n') f.write('interface\... |
'flapack_user_routines.pyf']) | 'flapack_user_routines.pyf', 'interface_gen.py']) | def generate_pyf(extension, build_dir): name = extension.name.split('.')[-1] target = join(build_dir,target_dir,name+'.pyf') if name[0]=='c' and atlas_version is None and newer(__file__,target): f = open(target,'w') f.write('python module '+name+'\n') f.write('usercode void empty_module(void) {}\n') f.write('interface\... |
'depends': map(local_join,['generic_clapack.pyf']) | 'depends': map(local_join,['generic_clapack.pyf', 'interface_gen.py']) | def generate_pyf(extension, build_dir): name = extension.name.split('.')[-1] target = join(build_dir,target_dir,name+'.pyf') if name[0]=='c' and atlas_version is None and newer(__file__,target): f = open(target,'w') f.write('python module '+name+'\n') f.write('usercode void empty_module(void) {}\n') f.write('interface\... |
elif mtype in ['f','float','float32','real*4']: | elif mtype in ['f','float','float32','real*4', 'real']: | def getsize_type(mtype): if mtype in ['b','uchar','byte','unsigned char','integer*1', 'int8']: mtype = 'b' elif mtype in ['c', 'char','char*1']: mtype = 'c' elif mtype in ['1','schar', 'signed char']: mtype = '1' elif mtype in ['s','short','int16','integer*2']: mtype = 's' elif mtype in ['i','int']: mtype = 'i' elif mt... |
elif mtype in ['d','double','float64','real*8']: | elif mtype in ['d','double','float64','real*8', 'double precision']: | def getsize_type(mtype): if mtype in ['b','uchar','byte','unsigned char','integer*1', 'int8']: mtype = 'b' elif mtype in ['c', 'char','char*1']: mtype = 'c' elif mtype in ['1','schar', 'signed char']: mtype = '1' elif mtype in ['s','short','int16','integer*2']: mtype = 's' elif mtype in ['i','int']: mtype = 'i' elif mt... |
sz,mtype = getsize_type(args[0]) | if len(args) > 0: sz,mtype = getsize_type(args[0]) else: sz,mtype = getsize_type(fmt.typecode()) | def fort_write(self,fmt,*args): """Write a Fortran binary record. |
name = ''.join(asarray(_get_element(fid)[0]).astype('c')) | name = asarray(_get_element(fid)[0]).tostring() | 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')) tupdims = tuple(dims[::-1]) if dclass in mxArrays: result, unused =_get_element(fid) if type == mxCHAR_CLASS: result = ''.join(asarray(result).astype('c')) ... |
except AtrributeError: | except AttributeError: | def getnzmax(self): try: nzmax = self.nzmax except AttributeError: try: nzmax = self.nnz except AtrributeError: nzmax = 0 return nzmax |
tcode = s.typecode func = getattr(sparsetools,tcode+'transp') | func = getattr(sparsetools,s.ftype+'transp') | def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csc') if isinstance(s,spmatrix): if isinstance(s, csc_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.rowind = s.rowind.copy() self.indptr = s.indptr.copy() else: ... |
func(s.data, s.colind, s.indptr) | func(s.shape[1], s.data, s.colind, s.indptr) | def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csc') if isinstance(s,spmatrix): if isinstance(s, csc_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.rowind = s.rowind.copy() self.indptr = s.indptr.copy() else: ... |
data1, data2 = _convert_data(self.data[:nnz1], other.data[:nnz2], typecode) | data1, data2 = _convert_data(self.data[:nnz1], ocs.data[:nnz2], typecode) | def __add__(self, other): ocs = csc_matrix(other) if (ocs.shape != self.shape): raise ValueError, "Inconsistent shapes." typecode = _coerce_rules[(self.typecode,other.typecode)] nnz1, nnz2 = self.nnz, other.nnz data1, data2 = _convert_data(self.data[:nnz1], other.data[:nnz2], typecode) func = getattr(sparsetools,_trans... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.