bugged stringlengths 4 228k | fixed stringlengths 0 96.3M | __index_level_0__ int64 0 481k |
|---|---|---|
def bilinear(b,a,fs=1.0): a,b = map(r1array,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = Float M = max([N,D]) Np = M Dp = M bprime = zeros(Np+1,artype) aprime = zeros(Dp+1,artype) for j in range(Np+1): val = 0.0 for i in range(N+1): for k in range(i+1): for l in range(M-i+1): if k+l == j: val += comb(i,k)*comb(M-i,l)*... | def bilinear(b,a,fs=1.0): a,b = map(r1array,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = Num.Float M = max([N,D]) Np = M Dp = M bprime = zeros(Np+1,artype) aprime = zeros(Dp+1,artype) for j in range(Np+1): val = 0.0 for i in range(N+1): for k in range(i+1): for l in range(M-i+1): if k+l == j: val += comb(i,k)*comb(M-i... | 600 |
def bilinear(b,a,fs=1.0): a,b = map(r1array,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = Float M = max([N,D]) Np = M Dp = M bprime = zeros(Np+1,artype) aprime = zeros(Dp+1,artype) for j in range(Np+1): val = 0.0 for i in range(N+1): for k in range(i+1): for l in range(M-i+1): if k+l == j: val += comb(i,k)*comb(M-i,l)*... | def bilinear(b,a,fs=1.0): a,b = map(r1array,(a,b)) D = len(a) - 1 N = len(b) - 1 artype = Float M = max([N,D]) Np = M Dp = M bprime = Num.zeros(Np+1,artype) aprime = Num.zeros(Dp+1,artype) for j in range(Np+1): val = 0.0 for i in range(N+1): for k in range(i+1): for l in range(M-i+1): if k+l == j: val += comb(i,k)*comb... | 601 |
def iirfilter(N, Wn, rp=None, rs=None, btype='band', analog=0, ftype='butter', output='ba'): """IIR digital and analog filter design given order and critical points. Description: Design an Nth order lowpass digital or analog filter and return the filter coefficients in (B,A) (numerator, denominator) or (Z,P,K) form. ... | def iirfilter(N, Wn, rp=None, rs=None, btype='band', analog=0, ftype='butter', output='ba'): """IIR digital and analog filter design given order and critical points. Description: Design an Nth order lowpass digital or analog filter and return the filter coefficients in (B,A) (numerator, denominator) or (Z,P,K) form. ... | 602 |
def buttord(wp, ws, gpass, gstop, analog=0): """Butterworth filter order selection. Description: Return the order of the lowest order digital Butterworth filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge frequencies,... | def buttord(wp, ws, gpass, gstop, analog=0): """Butterworth filter order selection. Description: Return the order of the lowest order digital Butterworth filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge frequencies,... | 603 |
def buttord(wp, ws, gpass, gstop, analog=0): """Butterworth filter order selection. Description: Return the order of the lowest order digital Butterworth filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge frequencies,... | def buttord(wp, ws, gpass, gstop, analog=0): """Butterworth filter order selection. Description: Return the order of the lowest order digital Butterworth filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge frequencies,... | 604 |
def cheb2ord(wp, ws, gpass, gstop, analog=0): """Chebyshev type II filter order selection. Description: Return the order of the lowest order digital Chebyshev Type II filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge... | def cheb2ord(wp, ws, gpass, gstop, analog=0): """Chebyshev type II filter order selection. Description: Return the order of the lowest order digital Chebyshev Type II filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge... | 605 |
def cheb2ord(wp, ws, gpass, gstop, analog=0): """Chebyshev type II filter order selection. Description: Return the order of the lowest order digital Chebyshev Type II filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge... | def cheb2ord(wp, ws, gpass, gstop, analog=0): """Chebyshev type II filter order selection. Description: Return the order of the lowest order digital Chebyshev Type II filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge... | 606 |
def cheb2ap(N,rs): """Return (z,p,k) zero, pole, gain for Nth order Chebyshev type II lowpass analog filter prototype with rs decibels of ripple in the stopband. """ de = 1.0/sqrt(10**(0.1*rs)-1) mu = arcsinh(1.0/de)/N if N % 2: m = N - 1 n = Num.concatenate((arange(1,N-1,2),arange(N+2,2*N,2))) else: m = N n = arange(... | def cheb2ap(N,rs): """Return (z,p,k) zero, pole, gain for Nth order Chebyshev type II lowpass analog filter prototype with rs decibels of ripple in the stopband. """ de = 1.0/sqrt(10**(0.1*rs)-1) mu = arcsinh(1.0/de)/N if N % 2: m = N - 1 n = Num.concatenate((Num.arange(1,N-1,2),Num.arange(N+2,2*N,2))) else: m = N n =... | 607 |
def cheb2ap(N,rs): """Return (z,p,k) zero, pole, gain for Nth order Chebyshev type II lowpass analog filter prototype with rs decibels of ripple in the stopband. """ de = 1.0/sqrt(10**(0.1*rs)-1) mu = arcsinh(1.0/de)/N if N % 2: m = N - 1 n = Num.concatenate((arange(1,N-1,2),arange(N+2,2*N,2))) else: m = N n = arange(... | def cheb2ap(N,rs): """Return (z,p,k) zero, pole, gain for Nth order Chebyshev type II lowpass analog filter prototype with rs decibels of ripple in the stopband. """ de = 1.0/sqrt(10**(0.1*rs)-1) mu = arcsinh(1.0/de)/N if N % 2: m = N - 1 n = Num.concatenate((arange(1,N-1,2),arange(N+2,2*N,2))) else: m = N n = Num.ara... | 608 |
def cheb2ap(N,rs): """Return (z,p,k) zero, pole, gain for Nth order Chebyshev type II lowpass analog filter prototype with rs decibels of ripple in the stopband. """ de = 1.0/sqrt(10**(0.1*rs)-1) mu = arcsinh(1.0/de)/N if N % 2: m = N - 1 n = Num.concatenate((arange(1,N-1,2),arange(N+2,2*N,2))) else: m = N n = arange(... | def cheb2ap(N,rs): """Return (z,p,k) zero, pole, gain for Nth order Chebyshev type II lowpass analog filter prototype with rs decibels of ripple in the stopband. """ de = 1.0/sqrt(10**(0.1*rs)-1) mu = arcsinh(1.0/de)/N if N % 2: m = N - 1 n = Num.concatenate((arange(1,N-1,2),arange(N+2,2*N,2))) else: m = N n = arange(... | 609 |
def ellipap(N,rp,rs): """Return (z,p,k) zeros, poles, and gain of an Nth order normalized prototype elliptic analog lowpass filter with rp decibels of ripple in the passband and a stopband rs decibels down. Broken... """ if N == 1: p = -sqrt(1.0/(10**(0.1*rp)-1.0)) k = -p z = [] return z, p, k eps = Num.sqrt(10**(0.1... | def ellipap(N,rp,rs): """Return (z,p,k) zeros, poles, and gain of an Nth order normalized prototype elliptic analog lowpass filter with rp decibels of ripple in the passband and a stopband rs decibels down. Broken... """ if N == 1: p = -sqrt(1.0/(10**(0.1*rp)-1.0)) k = -p z = [] return z, p, k eps = Num.sqrt(10**(0.1... | 610 |
def ellipap(N,rp,rs): """Return (z,p,k) zeros, poles, and gain of an Nth order normalized prototype elliptic analog lowpass filter with rp decibels of ripple in the passband and a stopband rs decibels down. Broken... """ if N == 1: p = -sqrt(1.0/(10**(0.1*rp)-1.0)) k = -p z = [] return z, p, k eps = Num.sqrt(10**(0.1... | def ellipap(N,rp,rs): """Return (z,p,k) zeros, poles, and gain of an Nth order normalized prototype elliptic analog lowpass filter with rp decibels of ripple in the passband and a stopband rs decibels down. Broken... """ if N == 1: p = -sqrt(1.0/(10**(0.1*rp)-1.0)) k = -p z = [] return z, p, k eps = Num.sqrt(10**(0.1... | 611 |
def __init__(self, parent, id = -1, pos=wx.wxPyDefaultPosition, size=wx.wxPyDefaultSize,**attr): wx.wxWindow.__init__(self, parent, id, pos,size) wx.EVT_PAINT(self,self.OnPaint) property_object.__init__(self,attr) background = wx.wxNamedColour(self.background_color) self.SetBackgroundColour(background) #self.SetBackgro... | def __init__(self, parent, id = -1, pos=wx.wxPyDefaultPosition, size=wx.wxPyDefaultSize,**attr): wx.wxWindow.__init__(self, parent, id, pos,size) wx.EVT_PAINT(self,self.OnPaint) property_object.__init__(self, attr) background = wx.wxNamedColour(self.background_color) self.SetBackgroundColour(background) #self.SetBackgr... | 612 |
def __init__(self, parent, id = -1, pos=wx.wxPyDefaultPosition, size=wx.wxPyDefaultSize,**attr): wx.wxWindow.__init__(self, parent, id, pos,size) wx.EVT_PAINT(self,self.OnPaint) property_object.__init__(self,attr) background = wx.wxNamedColour(self.background_color) self.SetBackgroundColour(background) #self.SetBackgro... | def __init__(self, parent, id = -1, pos=wx.wxPyDefaultPosition, size=wx.wxPyDefaultSize,**attr): wx.wxWindow.__init__(self, parent, id, pos,size) wx.EVT_PAINT(self,self.OnPaint) property_object.__init__(self,attr) background = wx.wxNamedColour(self.background_color) self.SetBackgroundColour(background) #self.SetBackgro... | 613 |
def layout_graph(self,graph_area,dc): self.axes = [] #data_x_bounds,data_y_bounds = [0,6.28], [-1.1,1000] #jeez this is unwieldy code... smalls = []; bigs =[] if len(self.line_list): p1,p2 = self.line_list.bounding_box() smalls.append(p1);bigs.append(p2) if len(self.image_list): p1,p2 = self.image_list.bounding_box()... | def layout_graph(self,graph_area,dc): self.axes = [] #data_x_bounds,data_y_bounds = [0,6.28], [-1.1,1000] #jeez this is unwieldy code... smalls = []; bigs =[] if len(self.line_list): p1,p2 = self.line_list.bounding_box() smalls.append(p1);bigs.append(p2) if len(self.image_list): p1,p2 = self.image_list.bounding_box()... | 614 |
def layout_graph(self,graph_area,dc): self.axes = [] #data_x_bounds,data_y_bounds = [0,6.28], [-1.1,1000] #jeez this is unwieldy code... smalls = []; bigs =[] if len(self.line_list): p1,p2 = self.line_list.bounding_box() smalls.append(p1);bigs.append(p2) if len(self.image_list): p1,p2 = self.image_list.bounding_box()... | def layout_graph(self,graph_area,dc): self.axes = [] #data_x_bounds,data_y_bounds = [0,6.28], [-1.1,1000] #jeez this is unwieldy code... smalls = []; bigs =[] if len(self.line_list): p1,p2 = self.line_list.bounding_box() smalls.append(p1);bigs.append(p2) if len(self.image_list): p1,p2 = self.image_list.bounding_box()... | 615 |
def draw_graph_area(self,dc=None): if not dc: dc = wx.wxClientDC(self) self.layout_data() # just to check how real time plot would go... | def draw_graph_area(self,dc=None): if not dc: dc = wx.wxClientDC(self) self.layout_data() # just to check how real time plot would go... | 616 |
def draw(self,dc=None): #if not len(self.line_list) or len(self.image_list): # return # resize if necessary #print 'draw' | def draw(self,dc=None): #if not len(self.line_list) or len(self.image_list): # return # resize if necessary #print 'draw' | 617 |
def draw(self,dc=None): #if not len(self.line_list) or len(self.image_list): # return # resize if necessary #print 'draw' | def draw(self,dc=None): #if not len(self.line_list) or len(self.image_list): # return # resize if necessary #print 'draw' | 618 |
def OnPrintPage(self, page): dc = self.GetDC() | def OnPrintPage(self, page): dc = self.GetDC() | 619 |
def __init__(self, parent=wx.NULL, id = -1, title = '', pos=wx.wxPyDefaultPosition, size=default_size,visible=1): wx.wxFrame.__init__(self, parent, id, title,pos,size) | def __init__(self, parent=wx.NULL, id = -1, title = '', pos=wx.wxPyDefaultPosition, size=default_size,visible=1): wx.wxFrame.__init__(self, parent, id, title,pos,size) | 620 |
def evaluate(self, points): """Evaluate the estimated pdf on a set of points. | def evaluate(self, points): """Evaluate the estimated pdf on a set of points. | 621 |
def xlabel(self,t): cmd = 'set xlabel "' + t + '"' self._replot(cmd) | def xtitle(self,t): cmd = 'set xlabel "' + t + '"' self._replot(cmd) | 622 |
def ylabel(self,t): cmd = 'set ylabel "' + t + '"' self._replot(cmd) | def ytitle(self,t): cmd = 'set ylabel "' + t + '"' self._replot(cmd) | 623 |
def zlabel(self,t): cmd = 'set zlabel "' + t + '"' self._replot(cmd) | def ztitle(self,t): cmd = 'set zlabel "' + t + '"' self._replot(cmd) | 624 |
def _figure_rtics(self,minval,maxval,guess=20): xr = abs(maxval-minval) l10 = log10(xr) fl = floor(l10) xnorm = 10**(l10-fl) #you can change the value of 5 # to something if you want more tics... posns = guess / xnorm if (posns > 40): tics = 0.05 # eg 0, .05, .10, ... if (posns > 20): tics = 0.1 # eg 0, .1, .... | def _figure_rtics(self,minval,maxval,guess=20): xr = abs(maxval-minval) l10 = log10(xr) fl = floor(l10) xnorm = 10**(l10-fl) #you can change the value of 5 # to something if you want more tics... posns = guess / xnorm if (posns > 40): tics = 0.05 # eg 0, .05, .10, ... if (posns > 20): tics = 0.1 # eg 0, .1, .... | 625 |
def __init__(self, val): UserList.UserList.__init__(self, val) | def __init__(self, val): UserList.UserList.__init__(self, val) | 626 |
def __init__(self, val): UserDict.UserDict.__init__(self, val) | def __init__(self, val): UserDict.UserDict.__init__(self, val) | 627 |
def configuration(parent_package=''): """ gist only works with an X-windows server This will install *.gs and *.gp files to '%spython%s/site-packages/scipy/xplt' % (sys.prefix,sys.version[:3]) """ # Check for X11 libraries try: execfile('../saved_values.py') try: X11 = X11 except NameError: X11 = check_and_save() excep... | def configuration(parent_package=''): """ gist only works with an X-windows server This will install *.gs and *.gp files to '%spython%s/site-packages/scipy/xplt' % (sys.prefix,sys.version[:3]) """ # Check for X11 libraries try: exec(open(save_file).read()) try: X11 = X11 except NameError: X11 = check_and_save() except ... | 628 |
def __setattr__(self,key,val): | def __setattr__(self,key,val): | 629 |
def getCSR(self): # Return Compressed Sparse Row format arrays for this matrix keys = self.keys() keys.sort() nnz = len(keys) data = [None]*nnz colind = [None]*nnz row_ptr = [None]*(self.shape[0]+1) current_row = -1 k = 0 for key in keys: ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey0 != current_row: current_row = ik... | def getCSR(self): # Return Compressed Sparse Row format arrays for this matrix keys = self.keys() keys.sort() nnz = len(keys) data = [None]*nnz colind = [None]*nnz row_ptr = [None]*(self.shape[0]+1) current_row = -1 k = 0 for key in keys: ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey0 != current_row: current_row = ik... | 630 |
def getCSC(self): # Return Compressed Sparse Column format arrays for this matrix keys = self.keys() keys.sort(csc_cmp) nnz = len(keys) data = [None]*nnz rowind = [None]*nnz col_ptr = [None]*(self.shape[1]+1) current_col = -1 k = 0 for key in keys: ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey1 != current_col: curren... | def getCSC(self): # Return Compressed Sparse Column format arrays for this matrix keys = self.keys() keys.sort(csc_cmp) nnz = len(keys) data = [None]*nnz rowind = [None]*nnz col_ptr = [None]*(self.shape[1]+1) current_col = -1 k = 0 for key in keys: ikey0 = int(key[0]) ikey1 = int(key[1]) if ikey1 != current_col: curren... | 631 |
def dense(self,typecode=None): if typecode is None: typecode = self.type if typecode is None: typecode = 'd' new = zeros(self.shape,typecode) for key in self.keys(): ikey0 = int(key[0]) ikey1 = int(key[1]) new[ikey0,ikey1] = self[key] return new | defdense(self,typecode=None):iftypecodeisNone:typecode=self.typeiftypecodeisNone:typecode='d'new=zeros(self.shape,typecode)forkeyinself.keys():ikey0=int(key[0])ikey1=int(key[1])new[ikey0,ikey1]=self[key]returnnew | 632 |
def __init__(self,s,i=None,j=None,M=None,N=None,nzmax=None, typecode=Float): if type(s) in [types.ListType, ArrayType]: s = array(s,copy=0,typecode=typecode) if s.typecode() not in 'fdFD': # only support these 4 types. s = s.astype('d') sz = len(s) i = array(i,typecode='l',copy=0) j = array(j,typecode='l',copy=0) if n... | def __init__(self,s,i=None,j=None,M=None,N=None,nzmax=None, typecode=Float): if isinstance(s, dictmatrix): ftype, nnz, data, index0, index1 = s.getCSR() self.ftype = ftype self.ptype = _itranstabl[ftype] self.lastel = nnz-1 self.data = data self.index = [index0+1, index1+1] M, N = s.shape nzmax = nnz elif type(s) in [t... | 633 |
def getCSR(self): return A.ftype, A.lastel+1, A.data, A.index[0]-1, A.index[1]-1 | def getCSR(self): return A.ftype, A.lastel+1, A.data, A.index[0]-1, A.index[1]-1 | 634 |
def getCSC(self): B = A.transp() return B.ftype, B.lastel+1, B.data, B.index[0]-1, B.index[1]-1 | def getCSC(self): B = self.transp() return B.ftype, B.lastel+1, B.data, B.index[0]-1, B.index[1]-1 | 635 |
def solve(A,b,permc_spec=2): if not hasattr(A, 'getCSR') and not hasattr(A, 'getCSC'): raise ValueError, "Sparse matrix must be able to return CSC format--"\ "A.getCSC()--or CSR format--A.getCSR()" if not hasattr(A,'shape'): raise ValueError, "Sparse matrix must be able to return shape (rows,cols) = A.shape" if hasattr... | def solve(A,b,permc_spec=2): if not hasattr(A, 'getCSR') and not hasattr(A, 'getCSC'): raise ValueError, "Sparse matrix must be able to return CSC format--"\ "A.getCSC()--or CSR format--A.getCSR()" if not hasattr(A,'shape'): raise ValueError, "Sparse matrix must be able to return shape (rows,cols) = A.shape" if hasattr... | 636 |
def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + ftype + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | 637 |
def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | 638 |
def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | 639 |
def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | 640 |
def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | def lu_factor(A, permc_spec=2, diag_pivot_thresh=1.0, drop_tol=0.0, relax=1, panel_size=10): ftype, nnz, data, rowind, colptr = A.getCSC() M,N = A.shape gstrf = eval('_superlu.' + _transtabl[ftype] + 'gstrf') return gstrf(M,N,nnz,data,rowind,colptr,permc_spec, diag_pivot_thresh, drop_tol, relax, panel_size) | 641 |
def prune(self): """ Remove empty space after all non-zero elements. """ nnz = self.indptr[-1] if self.nzmax <= nnz: if self.nzmax < nnz: raise RunTimeError, "should never have nnz > nzmax" return self.nnz = nnz self.data = self.data[:nnz] self.rowind = self.rowind[:nnz] self.nzmax = nnz self._check() | def prune(self): """ Remove empty space after all non-zero elements. """ nnz = self.indptr[-1] if self.nzmax <= nnz: if self.nzmax < nnz: raise RuntimeError, "should never have nnz > nzmax" return self.nnz = nnz self.data = self.data[:nnz] self.rowind = self.rowind[:nnz] self.nzmax = nnz self._check() | 642 |
def prune(self): """ Eliminate non-zero entries, leaving space for at least newnzmax elements. """ nnz = self.indptr[-1] if self.nzmax <= nnz: if self.nzmax < nnz: raise RunTimeError, "should never have nnz > nzmax" return self.data = self.data[:nnz] self.colind = self.colind[:nnz] self.nzmax = nnz self._check() | def prune(self): """ Eliminate non-zero entries, leaving space for at least newnzmax elements. """ nnz = self.indptr[-1] if self.nzmax <= nnz: if self.nzmax < nnz: raise RuntimeError, "should never have nnz > nzmax" return self.data = self.data[:nnz] self.colind = self.colind[:nnz] self.nzmax = nnz self._check() | 643 |
def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('special', parent_package, top_path) define_macros = [] | def configuration(parent_package='',top_path=None): from numpy.distutils.misc_util import Configuration config = Configuration('special', parent_package, top_path) define_macros = [] | 644 |
def eig(a,b=None,left=0,right=1,overwrite_a=0,overwrite_b=0): """ Solve ordinary and generalized eigenvalue problem of a square matrix. Inputs: a -- An N x N matrix. b -- An N x N matrix [default is identity(N)]. left -- Return left eigenvectors [disabled]. right -- Return right eigenvectors [enabled]. Outp... | def eig(a,b=None, left=False, right=True, overwrite_a=False, overwrite_b=False): """ Solve ordinary and generalized eigenvalue problem of a square matrix. Inputs: a -- An N x N matrix. b -- An N x N matrix [default is identity(N)]. left -- Return left eigenvectors [disabled]. right -- Return right eigenvecto... | 645 |
def eig(a,b=None,left=0,right=1,overwrite_a=0,overwrite_b=0): """ Solve ordinary and generalized eigenvalue problem of a square matrix. Inputs: a -- An N x N matrix. b -- An N x N matrix [default is identity(N)]. left -- Return left eigenvectors [disabled]. right -- Return right eigenvectors [enabled]. Outp... | def eig(a,b=None,left=0,right=1,overwrite_a=0,overwrite_b=0): """ Solve ordinary and generalized eigenvalue problem of a square matrix. Inputs: a -- An N x N matrix. b -- An N x N matrix [default is identity(N)]. left -- Return left eigenvectors [disabled]. right -- Return right eigenvectors [enabled]. Outp... | 646 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a, lower=True, eigvals_only=False, overwrite_a=False): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors.... | 647 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [True: UPLO='L' (default) / False: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwr... | 648 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 649 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 650 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 651 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 652 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 653 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 654 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 655 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 656 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 657 |
def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | def eigh(a,lower=1,eigvals_only=0,overwrite_a=0): """ Solve real symmetric or complex hermitian eigenvalue problem. Inputs: a -- A hermitian N x N matrix. lower -- values in a are read from lower triangle [1: UPLO='L' (default) / 0: UPLO='U'] eigvals_only -- don't compute eigenvectors. overwrite_a ... | 658 |
def matview(A,cmax=None,cmin=None,palette=None,color='black'): """Plot an image of a matrix. """ A = Numeric.asarray(A) if A.typecode() in ['D','F']: print "Warning: complex array given, plotting magnitude." A = Numeric.abs(A) M,N = A.shape A = A[::-1,:] if cmax is None: cmax = max(ravel(A)) if cmin is None: cmin = min... | def matview(A,cmax=None,cmin=None,palette=None,color='black'): """Plot an image of a matrix. """ A = Numeric.asarray(A) if A.typecode() in ['D','F']: print "Warning: complex array given, plotting magnitude." A = abs(A) M,N = A.shape A = A[::-1,:] if cmax is None: cmax = max(ravel(A)) if cmin is None: cmin = min(ravel(A... | 659 |
def compare_times(setup, expr): print "Expression:", expr numpy_timer = timeit.Timer(expr, setup) numpy_time = numpy_timer.timeit(number=iterations) print 'numpy:', numpy_time / iterations weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) weave_time = weave_timer.timeit(number=iterations) print "Weave:",... | def compare_times(setup, expr): print "Expression:", expr numpy_timer = timeit.Timer(expr, setup) numpy_time = numpy_timer.timeit(number=iterations) print 'numpy:', numpy_time / iterations try: weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) weave_time = weave_timer.timeit(number=iterations) print "Wea... | 660 |
def compare_times(setup, expr): print "Expression:", expr numpy_timer = timeit.Timer(expr, setup) numpy_time = numpy_timer.timeit(number=iterations) print 'numpy:', numpy_time / iterations weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) weave_time = weave_timer.timeit(number=iterations) print "Weave:",... | def compare_times(setup, expr): print "Expression:", expr numpy_timer = timeit.Timer(expr, setup) numpy_time = numpy_timer.timeit(number=iterations) print 'numpy:', numpy_time / iterations weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) weave_time = weave_timer.timeit(number=iterations) print "Weave:",... | 661 |
def compare_times(setup, expr): print "Expression:", expr numpy_timer = timeit.Timer(expr, setup) numpy_time = numpy_timer.timeit(number=iterations) print 'numpy:', numpy_time / iterations weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) weave_time = weave_timer.timeit(number=iterations) print "Weave:",... | def compare_times(setup, expr): print "Expression:", expr numpy_timer = timeit.Timer(expr, setup) numpy_time = numpy_timer.timeit(number=iterations) print 'numpy:', numpy_time / iterations weave_timer = timeit.Timer('blitz("result=%s")' % expr, setup) weave_time = weave_timer.timeit(number=iterations) print "Weave:",... | 662 |
def check(expr): try: if not alltrue(eval(expr) == evaluate(expr)): print ">>> %s: FAILED" % expr print " GOT :", evaluate(expr)[:3], "..." print " EXPECTED :", eval(expr)[:3], "..." return False else: print " %s" % expr#, evaluate(expr)[:3], "..." return True except StandardError, err: print ">>> %s: ERROR(%... | def check(expr): try: npval = eval(expr) neval = evaluate(expr) if not (shape(npval) == shape(neval) and alltrue(ravel(npval) == ravel(neval))): print ">>> %s: FAILED" % expr print " GOT :", evaluate(expr)[:3], "..." print " EXPECTED :", eval(expr)[:3], "..." return False else: print " %s" % expr#, evaluate(e... | 663 |
def check(expr): try: if not alltrue(eval(expr) == evaluate(expr)): print ">>> %s: FAILED" % expr print " GOT :", evaluate(expr)[:3], "..." print " EXPECTED :", eval(expr)[:3], "..." return False else: print " %s" % expr#, evaluate(expr)[:3], "..." return True except StandardError, err: print ">>> %s: ERROR(%... | def check(expr): try: if not alltrue(eval(expr) == evaluate(expr)): print ">>> %s: FAILED" % expr print " GOT :", neval[:3], "..." print " EXPECTED :", npval[:3], "..." return False else: print " %s" % expr#, evaluate(expr)[:3], "..." return True except StandardError, err: print ">>> %s: ERROR(%s)" % (expr, e... | 664 |
def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | def fixed_point(func, x0, args=(), xtol=1e-10, maxiter=500): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p... | 665 |
def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | 666 |
def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | 667 |
def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | def fixed_point(func, x0, args=(), tol=1e-10, maxiter=50): """Given a function of one variable and a starting point, find a fixed-point of the function: i.e. where func(x)=x. """ p0 = x0 for iter in range(maxiter): p1 = apply(func,(p0,)+args) p2 = apply(func,(p1,)+args) try: p = p0 - (p1 - p0)*(p1-p0) / (p2-2.0*p1+p0)... | 668 |
def draw(self,dc=None): #if not len(self.line_list) or len(self.image_list): # return # resize if necessary #print 'draw' t1 = time.clock();self.reset_size(dc);t2 = time.clock() #print 'resize:',t2 - t1 if not dc: dc = wx.wxClientDC(self) | def draw(self,dc=None): #if not len(self.line_list) or len(self.image_list): # return # resize if necessary #print 'draw' t1 = time.clock();self.reset_size(dc);t2 = time.clock() #print 'resize:',t2 - t1 if not dc: dc = wx.wxClientDC(self) | 669 |
def update(self): self.client_size = (0,0) # forces the layout self.Refresh() | def update(self,event=None): self.client_size = (0,0) # forces the layout self.Refresh() | 670 |
def func_and_grad(x): x = asarray(x) f = func(x, *args) g = fprime(x, *args) return f, list(g) | def func_and_grad(x): x = asarray(x) f = func(x, *args) g = fprime(x, *args) return f, list(g) | 671 |
def figure(which_one = None): global _figure; global _active if which_one == None: title ='Figure %d' % len(_figure) _figure.append(plot_class(title=title)) _active = _figure[-1] else: if (type(which_one) == type(1)) or (type(which_one) == type(1.)): try: _active = _figure[int(which_one)] except IndexError: msg = "Ther... | def figure(which_one = None): global _figure; global _active if which_one == None: title ='Figure %d' % len(_figure) _figure.append(plot_class(title=title)) _active = _figure[-1] else: if (type(which_one) == type(1)) or (type(which_one) == type(1.)): try: _active = _figure[int(which_one)] except IndexError: msg = "Ther... | 672 |
def test_smallest_same_kind(self): R = self.recaster value = 1 # smallest same kind # Define expected type output from same kind downcast of value required_types = {'complex': N.complex128, 'float': N.float64, 'int': N.int32, 'uint': None} for kind, req_type in required_types.items(): if req_type is not None: rdtsz = N... | def test_smallest_same_kind(self): R = self.recaster value = 1 # smallest same kind # Define expected type output from same kind downcast of value required_types = {'complex': N.complex128, 'float': N.float64, 'int': N.int32, 'uint': None} for kind, req_type in required_types.items(): if req_type is not None: rdtsz = N... | 673 |
def binompdf(k, n, pr=0.5): k = arr(k) assert (0<pr<1) cond = arr((k > 0) & (k == floor(k))) return where(cond, special.bdtr(k,n,pr)-special.bdtr(k-1,n,pr), 0.0) | def binompdf(k, n, pr=0.5): k = arr(k) assert (0<pr<1) cond = arr((k > 0) & (k == floor(k))) sv =errp(0) temp = special.bdtr(k,n,pr) temp2 = special.bdtr(k-1,n,pr) sv = errp(sv) return select([cond,k==0], [temp-temp2,temp],0.0) | 674 |
def buttord(wp, ws, gpass, gstop, analog=0): """Butterworth filter order selection. Description: Return the order of the lowest order digital Butterworth filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge frequencies,... | def buttord(wp, ws, gpass, gstop, analog=0): """Butterworth filter order selection. Description: Return the order of the lowest order digital Butterworth filter that loses no more than gpass dB in the passband and has at least gstop dB attenuation in the stopband. Inputs: wp, ws -- Passb and stopb edge frequencies,... | 675 |
def mathieu_odd_coef(m,q): """Compute expansion coefficients for even mathieu functions and modified mathieu functions. """ if not (isscalar(m) and isscalar(q)): raise ValueError, "m and q must be scalars." if (q < 0): raise ValueError, "q >=0" if (m != floor(m)) or (m<=0): raise ValueError, "m must be an integer > 0" ... | defmathieu_odd_coef(m,q):"""Computeexpansioncoefficientsforevenmathieufunctionsandmodifiedmathieufunctions."""ifnot(isscalar(m)andisscalar(q)):raiseValueError,"mandqmustbescalars."if(q<0):raiseValueError,"q>=0"if(m!=floor(m))or(m<=0):raiseValueError,"mmustbeaninteger>0"if(q<=1):qm=7.5+56.1*sqrt(q)-134.7*q+90.7*sqrt(q)*... | 676 |
def lpmn(m,n,z): """Associated Legendre functions of the second kind, Pmn(z) and its derivative, Pmn'(z) of order m and degree n. Returns two arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for all orders from 0..m and degrees from 0..n. z can be complex. """ if not isscalar(m) or (m<0): raise ValueError, "m m... | def lpmn(m,n,z): """Associated Legendre functions of the second kind, Pmn(z) and its derivative, Pmn'(z) of order m and degree n. Returns two arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for all orders from 0..m and degrees from 0..n. z can be complex. """ if not isscalar(m) or (abs(m)>n): raise ValueError,... | 677 |
def lpmn(m,n,z): """Associated Legendre functions of the second kind, Pmn(z) and its derivative, Pmn'(z) of order m and degree n. Returns two arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for all orders from 0..m and degrees from 0..n. z can be complex. """ if not isscalar(m) or (m<0): raise ValueError, "m m... | def lpmn(m,n,z): """Associated Legendre functions of the second kind, Pmn(z) and its derivative, Pmn'(z) of order m and degree n. Returns two arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for all orders from 0..m and degrees from 0..n. z can be complex. """ if not isscalar(m) or (m<0): raise ValueError, "m m... | 678 |
def lpmn(m,n,z): """Associated Legendre functions of the second kind, Pmn(z) and its derivative, Pmn'(z) of order m and degree n. Returns two arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for all orders from 0..m and degrees from 0..n. z can be complex. """ if not isscalar(m) or (m<0): raise ValueError, "m m... | def lpmn(m,n,z): """Associated Legendre functions of the second kind, Pmn(z) and its derivative, Pmn'(z) of order m and degree n. Returns two arrays of size (m+1,n+1) containing Pmn(z) and Pmn'(z) for all orders from 0..m and degrees from 0..n. z can be complex. """ if not isscalar(m) or (m<0): raise ValueError, "m m... | 679 |
def _valfrommode(mode): try: val = _modedict[mode] except KeyError: if val not in [0,1,2]: raise ValueError, "Acceptable mode flags are 'valid' (0), 'same' (1), or 'full' (2)." val = mode return val | def _valfrommode(mode): try: val = _modedict[mode] except KeyError: if mode not in [0,1,2]: raise ValueError, "Acceptable mode flags are 'valid' (0), 'same' (1), or 'full' (2)." val = mode return val | 680 |
def __init__(self, mat_stream, byte_order=None, base_name='raw', matlab_compatible=False, squeeze_me=True, chars_as_strings=True, ): # Initialize stream self.mat_stream = mat_stream self.dtypes = {} if not byte_order: byte_order = self.guess_byte_order() self.order_code = byte_order # sets dtypes and other things too s... | def __init__(self, mat_stream, byte_order=None, base_name='raw', matlab_compatible=False, squeeze_me=True, chars_as_strings=True, ): # Initialize stream self.mat_stream = mat_stream self.dtypes = {} if not byte_order: byte_order = self.guess_byte_order() self.order_code = byte_order # sets dtypes and other things too s... | 681 |
def set_matlab_compatible(self, matlab_compatible): self._matlab_compatible = matlab_compatible if matlab_compatible: self.squeeze_me = False self.char_as_strings = False self.processor_func = self.get_processor_func() | def set_matlab_compatible(self, m_l_c): self._matlab_compatible = m_l_c if m_l_c: self._squeeze_me = False self._chars_as_strings = False self.processor_func = self.get_processor_func() | 682 |
def func(arr, getter): if arr.dtype.kind == 'U' and self.chars_as_strings: # Convert char array to string or array of strings dims = arr.shape if len(dims) >= 2: # return array of strings dtt = self.order_code + 'U' n_dims = dims[:-1] str_arr = reshape(arr, (small_product(n_dims), dims[-1])) arr = empty(n_dims, dtype=o... | def func(arr, getter): if arr.dtype.kind == 'U' and self.chars_as_strings: # Convert char array to string or array of strings dims = arr.shape if len(dims) >= 2: # return array of strings dtt = self.order_code + 'U' n_dims = dims[:-1] str_arr = reshape(arr, (small_product(n_dims), dims[-1])) arr = empty(n_dims, dtype=o... | 683 |
def all_subroutines(interface_in): # remove comments comment_block_exp = re.compile(r'/\*(?:\s|.)*?\*/') subroutine_exp = re.compile(r'subroutine (?:\s|.)*?end subroutine.*') function_exp = re.compile(r'function (?:\s|.)*?end function.*') interface = comment_block_exp.sub('',interface_in) subroutine_list = subroutine_... | defall_subroutines(interface_in):#removecommentscomment_block_exp=re.compile(r'/\*(?:\s|.)*?\*/')subroutine_exp=re.compile(r'subroutine(?:\s|.)*?endsubroutine.*')function_exp=re.compile(r'function(?:\s|.)*?endfunction.*')interface=comment_block_exp.sub('',interface_in)subroutine_list=subroutine_exp.findall(interface)fu... | 684 |
def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a re... | def __init__(self, x, y, z, kind='linear', copy=True, bounds_error=False, fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise... | 685 |
def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a re... | def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a reference is ... | 686 |
def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a re... | def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a re... | 687 |
def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a re... | def __init__(self,x,y,z,kind='linear', copy=True,bounds_error=0,fill_value=None): """ Input: x,y - 1-d arrays defining 2-d grid (or 2-d meshgrid arrays) z - 2-d array of grid values kind - interpolation type ('nearest', 'linear', 'cubic', 'quintic') copy - if true then data is copied into class, otherwise only a re... | 688 |
def __call__(self,x,y,dx=0,dy=0): """ Input: x,y - 1-d arrays defining points to interpolate. dx,dy - order of partial derivatives in x and y, respectively. 0<=dx<kx, 0<=dy<ky Output: z - 2-d array of interpolated values """ x = atleast_1d(x) y = atleast_1d(y) z,ier=fitpack._fitpack._bispev(*(self.tck+[x,y,dx,dy]... | def __call__(self,x,y,dx=0,dy=0): """ Input: x,y - 1-d arrays defining points to interpolate. dx,dy - order of partial derivatives in x and y, respectively. 0<=dx<kx, 0<=dy<ky Output: z - 2-d array of interpolated values """ x = atleast_1d(x) y = atleast_1d(y) z,ier=fitpack.bisplev(self.tck, x, y, dx, dy) if ier=... | 689 |
def __call__(self,x,y,dx=0,dy=0): """ Input: x,y - 1-d arrays defining points to interpolate. dx,dy - order of partial derivatives in x and y, respectively. 0<=dx<kx, 0<=dy<ky Output: z - 2-d array of interpolated values """ x = atleast_1d(x) y = atleast_1d(y) z,ier=fitpack._fitpack._bispev(*(self.tck+[x,y,dx,dy]... | def __call__(self,x,y,dx=0,dy=0): """ Input: x,y - 1-d arrays defining points to interpolate. dx,dy - order of partial derivatives in x and y, respectively. 0<=dx<kx, 0<=dy<ky Output: z - 2-d array of interpolated values """ x = atleast_1d(x) y = atleast_1d(y) z,ier=fitpack._fitpack._bispev(*(self.tck+[x,y,dx,dy]... | 690 |
def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | def gmres(A,b,restrt=None,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-... | 691 |
def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | 692 |
def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | 693 |
def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | def gmres(A,b,x0=None,tol=1e-5,maxiter=None): """Use Generalized Minimal RESidual iteration to solve A x = b Inputs: A -- An array or an object with a matvec(x) method to represent A * x. May also have a psolve(b) methods for representing solution to the preconditioning equation M * x = b. b -- An n-length vecto... | 694 |
fpedef = "-DFPU_HPUX" | fpedef = "-DFPU_HPUX" | 695 |
fpedef = "-DFPU_HPUX" | fpedef = "-DFPU_HPUX" | 696 |
def check_axpy(self): for p in 'sd': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2,3],[2,-1,3]),[7,9,18]) f = getattr(fblas,p+'axpy') assert_array_almost_equal(f([1,2,3],[2,-1,3]),[7,9,18],a=5) for p in 'cz': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2j,3],[2,-1,3]),[7,10j-1,18]) f =... | def check_axpy(self): for p in 'sd': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2,3],[2,-1,3]),[7,9,18]) f = getattr(fblas,p+'axpy') assert_array_almost_equal(f([1,2,3],[2,-1,3],a=5),[7,9,18]) for p in 'cz': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2j,3],[2,-1,3]),[7,10j-1,18]) f =... | 697 |
def check_axpy(self): for p in 'sd': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2,3],[2,-1,3]),[7,9,18]) f = getattr(fblas,p+'axpy') assert_array_almost_equal(f([1,2,3],[2,-1,3]),[7,9,18],a=5) for p in 'cz': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2j,3],[2,-1,3]),[7,10j-1,18]) f =... | def check_axpy(self): for p in 'sd': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2,3],[2,-1,3]),[7,9,18]) f = getattr(fblas,p+'axpy') assert_array_almost_equal(f([1,2,3],[2,-1,3]),[7,9,18],a=5) for p in 'cz': f = getattr(cblas,p+'axpy') assert_array_almost_equal(f(5,[1,2j,3],[2,-1,3]),[7,10j-1,18]) f =... | 698 |
def check_basic(self): ba = [1,2,10,11,6,5,4] ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]] for ctype in ['1','b','s','i','l','f','d','F','D']: a = array(ba,ctype) a2 = array(ba2,ctype) if ctype in ['1', 'b']: self.failUnlessRaises(ArithmeticError, cumprod, a) self.failUnlessRaises(ArithmeticError, cumprod, a2, 1) self.failUn... | def check_basic(self): ba = [1,2,10,11,6,5,4] ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]] for ctype in ['1','b','s','i','l','f','d','F','D']: a = array(ba,ctype) a2 = array(ba2,ctype) if ctype in ['1', 'b']: self.failUnlessRaises(ArithmeticError, cumprod, a) self.failUnlessRaises(ArithmeticError, cumprod, a2, 1) self.failUn... | 699 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.