bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
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...
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...
1,000
def _pmf(self, k, lambda_): fact = (1-exp(-lamba_)) return fact*exp(-lambda_(k))
def _pmf(self, k, lambda_): fact = (1-exp(-lambda_)) return fact*exp(-lambda_(k))
1,001
def check_stdX(self): y = scipy.stats.stdev(X) assert_almost_equal(y,2.738612788)
def check_stdX(self): y = scipy.stats.std(X) assert_almost_equal(y,2.738612788)
1,002
def check_stdZERO(self): y = scipy.stats.stdev(ZERO) assert_almost_equal(y,0.0)
def check_stdZERO(self): y = scipy.stats.std(ZERO) assert_almost_equal(y,0.0)
1,003
def check_stdBIG(self): y = scipy.stats.stdev(BIG) assert_almost_equal(y,2.738612788)
def check_stdBIG(self): y = scipy.stats.std(BIG) assert_almost_equal(y,2.738612788)
1,004
def check_stdLITTLE(self): y = scipy.stats.stdev(LITTLE) assert_approx_equal(y,2.738612788e-8)
def check_stdLITTLE(self): y = scipy.stats.std(LITTLE) assert_approx_equal(y,2.738612788e-8)
1,005
def check_stdHUGE(self): y = scipy.stats.stdev(HUGE) assert_approx_equal(y,2.738612788e12)
def check_stdHUGE(self): y = scipy.stats.std(HUGE) assert_approx_equal(y,2.738612788e12)
1,006
def check_stdTINY(self): y = scipy.stats.stdev(TINY) assert_almost_equal(y,0.0)
def check_stdTINY(self): y = scipy.stats.std(TINY) assert_almost_equal(y,0.0)
1,007
def check_stdROUND(self): y = scipy.stats.stdev(ROUND) assert_approx_equal(y,2.738612788)
def check_stdROUND(self): y = scipy.stats.std(ROUND) assert_approx_equal(y,2.738612788)
1,008
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 ...
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 ...
1,009
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...
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, 19391512145l,2404879675441l, 370371188237525l,69348874393137901l, 15514534163557086905l] c...
1,010
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 __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...
1,011
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 __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...
1,012
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 __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...
1,013
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
1,014
def _ppf_single_call(self, q, *args): return scipy.optimize.brentq(self._ppf_tosolve, 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)
1,015
def _ppf(self,q): return special.kolmogi(1.0-q)
def _ppf(self,q): return special.kolmogi(1.0-q)
1,016
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*...
defdef _entropy(self, c): k = log(1+c) return k/2.0 - log(c/k) _stats(self,def _entropy(self, c): k = log(1+c) return k/2.0 - log(c/k) c,def _entropy(self, c): k = log(1+c) return k/2.0 - log(c/k) moments='mv'):def _entropy(self, c): k = log(1+c) return k/2.0 - log(c/k) kdef _entropy(self, c): k = log(1+c) return k/2.0...
1,017
def _stats(self, x, c): return burr_gen._stats(self, x, c, 1.0)
def _stats(self, x, c): return burr_gen._stats(self, x, c, 1.0)
1,018
def _isf(self, q, dfn, dfd): return special.fdtri(dfn, dfd, q)
def _isf(self, q, dfn, dfd): return special.fdtri(dfn, dfd, q)
1,019
def _ppf(self, q, dfn, dfd): return self._isf(1.0-q, dfn, dfd)
def _ppf(self, q, dfn, dfd): return self._isf(1.0-q, dfn, dfd)
1,020
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)
def _argcheck(self, c): c = arr(c) self.b = where(c < 0, 1.0/abs(c), scipy.inf) return where(c==0, 0, 1)
1,021
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)
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)
1,022
def _ppf(self, q, c): return pow(-log(q),arr(-1.0/c))
def _ppf(self, q, c): return pow(-log(q),arr(-1.0/c))
1,023
def _stats(self): return 0, pi*pi/3.0, 0, 6.0/5.0
def _stats(self): return 0, pi*pi/3.0, 0, 6.0/5.0
1,024
def _stats(self, x): return 0, 0.25, 0, -1.0
def _stats(self): return 0, 0.25, 0, -1.0
1,025
def _stats(self, lam): return 0, None, 0, None
def _stats(self, lam): return 0, None, 0, None
1,026
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
def _cdf(self, x, c): output = 0.0*x val = (1.0+c)/(1.0-c) c1 = x<pi c2 = 1-c1 xp = extract( c1,x) valp = extract(c1,val) xn = extract( c2,x) valn = extract(c2,val) 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(va...
1,027
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
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(valn*yn) insert(output, c2, on) if (any(xp)): yp = tan(xp/2.0) op = 1.0/pi*arctan(val*yp) insert(output, x<pi, op) return output
1,028
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
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
1,029
def __call__(self, *args, **kwds): raise ValueError return self.freeze(*args,**kwds)
def __call__(self, *args, **kwds): return self.freeze(*args,**kwds)
1,030
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
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
1,031
def _stats(self, pr): return binom_gen._stats(self, 1, pr)
def _stats(self, pr): return binom_gen._stats(self, 1, pr)
1,032
def _argcheck(self, n, pr): self.a = n return (n >= 0) & (pr >= 0) & (pr <= 1)
def _argcheck(self, n, pr): return (n >= 0) & (pr >= 0) & (pr <= 1)
1,033
def _stats(self, mu): var = mu g1 = 1.0/arr(sqrt(mu)) g2 = 1.0 / arr(mu) return mu, var, g1, g2
def _stats(self, mu): var = mu g1 = 1.0/arr(sqrt(mu)) g2 = 1.0 / arr(mu) return mu, var, g1, g2
1,034
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
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
1,035
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...
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...
1,036
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, ...
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, ...
1,037
def _stats(self): return 0.5, 1.0/12, 0, -1.2
def _stats(self): return 0.5, 1.0/12, 0, -1.2
1,038
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...
def configuration(parent_package='', top_path=None): config = Configuration('delaunay', parent_package, top_path) config.add_extension("_delaunay", sources=["_delaunay.cpp", "VoronoiDiagramGenerator.cpp", "delaunay_utils.cpp", "natneighbors.cpp"], include_dirs=[local_path], ) return config
1,039
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...
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=['.'], ) return con...
1,040
def tri(N, M=None, k=0, typecode=None): """ returns a N-by-M matrix where all the diagonals starting from lower left corner up to the k-th are all ones. """ if M is None: M = N if type(M) == type('d'): typecode = M M = N m = greater_equal(subtract.outer(arange(N), arange(M)),-k) if typecode is None: return m else: retu...
def tri(N, M=None, k=0, typecode=None): """ returns a N-by-M matrix where all the diagonals starting from lower left corner up to the k-th are all ones. """ if M is None: M = N if type(M) == type('d'): typecode = M M = N m = greater_equal(subtract.outer(arange(N), arange(M)),-k) if typecode is None: return m else: re...
1,041
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
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 = getattr(m,'spacesaver',lambda:0)() m = asarray(m,savespace=1) out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m out.savespace(svsp) ret...
1,042
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
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 = getattr(m,'spacesaver',lambda:0)() m = asarray(m,savespace=1) out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m out.savespace(svsp) return o...
1,043
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 -- ...
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 (must accept vector inputs) a -- lower limit of integration b -- upper li...
1,044
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....
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....
1,045
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...
def configuration(parent_package='',parent_path=None): from scipy_distutils.core import Extension from scipy_distutils.misc_util import dot_join, get_path, default_config_dict from scipy_distutils.system_info import get_info, dict_append, NotFoundError package = 'linalg' from interface_gen import generate_interface co...
1,046
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\...
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\...
1,047
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\...
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\...
1,048
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\...
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\...
1,049
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\...
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\...
1,050
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...
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...
1,051
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...
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...
1,052
def fort_write(self,fmt,*args): """Write a Fortran binary record.
def fort_write(self,fmt,*args): """Write a Fortran binary record.
1,053
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')) ...
def _parse_mimatrix(fid,bytes): dclass, cmplx, nzmax =_parse_array_flags(fid) dims = _get_element(fid)[0] name = asarray(_get_element(fid)[0]).tostring() tupdims = tuple(dims[::-1]) if dclass in mxArrays: result, unused =_get_element(fid) if type == mxCHAR_CLASS: result = ''.join(asarray(result).astype('c')) else: if c...
1,054
def getnzmax(self): try: nzmax = self.nzmax except AttributeError: try: nzmax = self.nnz except AtrributeError: nzmax = 0 return nzmax
def getnzmax(self): try: nzmax = self.nzmax except AttributeError: try: nzmax = self.nnz except AttributeError: nzmax = 0 return nzmax
1,055
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: ...
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: ...
1,056
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: ...
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: ...
1,057
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...
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], ocs.data[:nnz2], typecode) func = getattr(sparsetools,_transta...
1,058
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...
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...
1,059
def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csr') if isinstance(s,spmatrix): if isinstance(s, csr_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.colind = s.colind.copy() self.indptr = s.indptr.copy() else: ...
def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csr') if isinstance(s,spmatrix): if isinstance(s, csr_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.colind = s.colind.copy() self.indptr = s.indptr.copy() else: ...
1,060
def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csr') if isinstance(s,spmatrix): if isinstance(s, csr_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.colind = s.colind.copy() self.indptr = s.indptr.copy() else: ...
def __init__(self,s,ij=None,M=None,N=None,nzmax=100,typecode=Float,copy=0): spmatrix.__init__(self, 'csr') if isinstance(s,spmatrix): if isinstance(s, csr_matrix): # do nothing but copy information self.shape = s.shape if copy: self.data = s.data.copy() self.colind = s.colind.copy() self.indptr = s.indptr.copy() else: ...
1,061
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != nzmax): raise ValueError, "Data and row list should have same length" if (len(self.indptr) != M+1): rais...
1,062
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
1,063
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
1,064
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
def _check(self): M,N = self.shape if (rank(self.data) != 1) or (rank(self.colind) != 1) or \ (rank(self.indptr) != 1): raise ValueError, "Data, colind, and indptr arrays "\ "should be rank 1." if (len(self.data) != len(self.colind)): raise ValueError, "Data and row list should have same length" if (len(self.indptr) !=...
1,065
def transp(self, copy=0): M,N = self.shape new = csr_matrix(N,M,nzmax=0,typecode=self.typecode) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
def transp(self, copy=0): M,N = self.shape new = csc_matrix(N,M,nzmax=0,typecode=self.typecode) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
1,066
def transp(self, copy=0): M,N = self.shape new = csr_matrix(N,M,nzmax=0,typecode=self.typecode) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
def transp(self, copy=0): M,N = self.shape new = csr_matrix(N,M,nzmax=0,typecode=self.typecode) if copy: new.data = self.data.copy() new.rowind = self.colind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
1,067
def transp(self, copy=0): M,N = self.shape new = csr_matrix(N,M,nzmax=0,typecode=self.typecode) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
def transp(self, copy=0): M,N = self.shape new = csr_matrix(N,M,nzmax=0,typecode=self.typecode) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.rowind = self.colind new.indptr = self.indptr new._check() return new
1,068
def _parse_header(fid, dict): correct_endian = (ord('M')<<8) + ord('I') # if this number is read no BS fid.seek(126) # skip to endian detector endian_test = fid.read(1,'int16') if (endian_test == correct_endian): openstr = 'n' else: # must byteswap if LittleEndian: openstr = 'b' else: openstr = 'l' fid.setformat(open...
def _parse_header(fid, dict): correct_endian = (ord('M')<<8) + ord('I') # if this number is read no BS fid.seek(126) # skip to endian detector endian_test = fid.read(1,'int16') if (endian_test == correct_endian): openstr = 'n' else: # must byteswap if LittleEndian: openstr = 'b' else: openstr = 'l' fid.setformat(open...
1,069
def _get_element(fid): test = fid.fid.read(1) if len(test) == 0: # nothing left raise EOFError else: fid.rewind(1) # get the data tag raw_tag = fid.read(1,'u') # check for compressed numbytes = raw_tag >> 16 if numbytes > 0: # compressed format if numbytes > 4: raise IOError, "Problem with MAT file: " \ "too many b...
def _get_element(fid): test = fid.raw_read(1) if len(test) == 0: # nothing left raise EOFError else: fid.rewind(1) # get the data tag raw_tag = fid.read(1,'u') # check for compressed numbytes = raw_tag >> 16 if numbytes > 0: # compressed format if numbytes > 4: raise IOError, "Problem with MAT file: " \ "too many b...
1,070
def valarray(shape,value=nan,typecode=None): """Return an array of all value. """ out = reshape(repeat([value],product(shape)),shape) if typecode is None: return out else: return out.astype(typecode)
def valarray(shape,value=nan,typecode=None): """Return an array of all value. """ out = reshape(repeat([value],product(shape)),shape) if typecode is not None: out = out.astype(typecode) if not isinstance(out, ndarray): out = asarray(out) return out
1,071
def validate_active(): global _active if _active is None: figure() try: if not _active.window_is_alive(): _active = None figure() except: pass
def validate_active(): global _active if _active is None: figure() try: if not _active.proxy_object_alive: _active = None figure() except: pass
1,072
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 """ 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 = Num.zeros(Np+1,artype) aprime = Num.zeros(D...
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(r1array,(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) aprime...
1,073
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. ...
1,074
def __setitem__(self, index, x): try: assert len(index) == 2 except (AssertionError, TypeError): raise IndexError, "invalid index" i, j = index if isinstance(i, int): if not (i>=0 and i<self.shape[0]): raise IndexError, "lil_matrix index out of range" else: if isinstance(i, slice): seq = xrange(i.start or 0, i.stop or ...
def __setitem__(self, index, x): try: assert len(index) == 2 except (AssertionError, TypeError): raise IndexError, "invalid index" i, j = index if isinstance(i, int): if not (i>=0 and i<self.shape[0]): raise IndexError, "lil_matrix index out of range" else: if isinstance(i, slice): seq = xrange(i.start or 0, i.stop or ...
1,075
def tmax(a,upperlimit,axis=0,inclusive=True): """Returns the maximum value of a, along axis, including only values greater than (or equal to, if inclusive is True) upperlimit. If the limit is set to None, a limit larger than the max value in the array is used. """ a, axis = asarray(a, axis) if inclusive: upperfc...
def tmax(a,upperlimit,axis=0,inclusive=True): """Returns the maximum value of a, along axis, including only values greater than (or equal to, if inclusive is True) upperlimit. If the limit is set to None, a limit larger than the max value in the array is used. """ a, axis = _chk_asarray(a, axis) if inclusive: up...
1,076
def check_basic(self): a1 = [1,-4,4] a2 = [4,-16,16] a3 = [1,5,6] assert_array_almost_equal(roots(a1),[2,2],11) assert_array_almost_equal(roots(a2),[2,2],11) assert_array_almost_equal(sort(roots(a3)),sort([-3,-2]),11)
def check_basic(self): a1 = [1,-4,4] a2 = [4,-16,16] a3 = [1,5,6] assert_array_almost_equal(roots(a1),[2,2],11) assert_array_almost_equal(roots(a2),[2,2],11) assert_array_almost_equal(sort(roots(a3)),sort([-3,-2]),11)
1,077
def check_inverse(self): a = rand(5) assert_array_almost_equal(sort(roots(poly(a))),sort(a),11)
def check_inverse(self): a = rand(5) assert_array_almost_equal(sort(roots(poly(a))),sort(a),11)
1,078
def check_nd(self): x = sort(20*rand(10,20,30)) y = x**2 + 2*x + 1 dx = x[:,1:,:] - x[:,:-1,:] val = add.reduce(dx*(y[:,1:,:] + y[:,:-1,:])/2.0,1) assert_array_equal(trapz(y,x,1),val)
def check_nd(self): x = sort(20*rand(10,20,30)) y = x**2 + 2*x + 1 dx = x[:,1:,:] - x[:,:-1,:] val = add.reduce(dx*(y[:,1:,:] + y[:,:-1,:])/2.0,1) assert_array_equal(trapz(y,x,1),val)
1,079
def blackman(M): """blackman(M) returns the M-point Blackman window. """ n = arange(0,M) return 0.42-0.5*cos(2.0*pi*n/(M-1)) + 0.08*cos(4.0*pi*n/(M-1))
def blackman(M): """The M-point Blackman window. """ n = arange(0,M) return 0.42-0.5*cos(2.0*pi*n/(M-1)) + 0.08*cos(4.0*pi*n/(M-1))
1,080
def bartlett(M): """bartlett(M) returns the M-point Bartlett window. """ n = arange(0,M) return where(less_equal(n,(M-1)/2.0),2.0*n/(M-1),2.0-2.0*n/(M-1))
def bartlett(M): """The M-point Bartlett window. """ n = arange(0,M) return where(less_equal(n,(M-1)/2.0),2.0*n/(M-1),2.0-2.0*n/(M-1))
1,081
def hanning(M): """hanning(M) returns the M-point Hanning window. """ n = arange(0,M) return 0.5-0.5*cos(2.0*pi*n/(M-1))
def hanning(M): """The M-point Hanning window. """ n = arange(0,M) return 0.5-0.5*cos(2.0*pi*n/(M-1))
1,082
def hamming(M): """hamming(M) returns the M-point Hamming window. """ n = arange(0,M) return 0.54-0.46*cos(2.0*pi*n/(M-1))
def hamming(M): """The M-point Hamming window. """ n = arange(0,M) return 0.54-0.46*cos(2.0*pi*n/(M-1))
1,083
def kaiser(M,beta): """kaiser(M, beta) returns a Kaiser window of length M with shape parameter beta. It depends on the cephes module for the modified bessel function i0. """ n = arange(0,M) alpha = (M-1)/2.0 return special.i0(beta * sqrt(1-((n-alpha)/alpha)**2.0))/special.i0(beta)
def kaiser(M,beta): """Returns a Kaiser window of length M with shape parameter beta. """ n = arange(0,M) alpha = (M-1)/2.0 return special.i0(beta * sqrt(1-((n-alpha)/alpha)**2.0))/special.i0(beta)
1,084
def configuration(parent_package=''): package = 'linalg' from interface_gen import generate_interface config = default_config_dict(package,parent_package) local_path = get_path(__name__) atlas_info = get_info('atlas') #atlas_info = {} # uncomment if ATLAS is available but want to use # Fortran LAPACK/BLAS; useful for ...
def configuration(parent_package=''): package = 'linalg' from interface_gen import generate_interface config = default_config_dict(package,parent_package) local_path = get_path(__name__) atlas_info = get_info('atlas') #atlas_info = {} # uncomment if ATLAS is available but want to use # Fortran LAPACK/BLAS; useful for ...
1,085
def mmwrite(target,a,comment='',field=None,precision=None): """ Writes the sparse or dense matrix A to a Matrix Market formatted file. Inputs: target - Matrix Market filename (extension .mtx) or open file object a - sparse or full matrix comment - comments to be prepended to the Matrix Market file field ...
def mmwrite(target,a,comment='',field=None,precision=None): """ Writes the sparse or dense matrix A to a Matrix Market formatted file. Inputs: target - Matrix Market filename (extension .mtx) or open file object a - sparse or full matrix comment - comments to be prepended to the Matrix Market file field ...
1,086
def mmwrite(target,a,comment='',field=None,precision=None): """ Writes the sparse or dense matrix A to a Matrix Market formatted file. Inputs: target - Matrix Market filename (extension .mtx) or open file object a - sparse or full matrix comment - comments to be prepended to the Matrix Market file field ...
def mmwrite(target,a,comment='',field=None,precision=None): """ Writes the sparse or dense matrix A to a Matrix Market formatted file. Inputs: target - Matrix Market filename (extension .mtx) or open file object a - sparse or full matrix comment - comments to be prepended to the Matrix Market file field ...
1,087
def resize1d(arr, newlen): old = len(arr) new = zeros((newlen,), arr.dtype.char) new[:old] = arr return new
def resize1d(arr, newlen): old = len(arr) new = zeros((newlen,), arr.dtype) new[:old] = arr return new
1,088
def __repr__(self): format = self.getformat() return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ "elements (space for %d)\n\tin %s format>" % \ (self.shape + (self.dtype.char, self.getnnz(), self.nzmax, \ _formats[format][1]))
def __repr__(self): format = self.getformat() return "<%dx%d sparse matrix of type '%s'\n\twith %d stored "\ "elements (space for %d)\n\tin %s format>" % \ (self.shape + (self.dtype.type, self.getnnz(), self.nzmax, \ _formats[format][1]))
1,089
def _real(self): csc = self.tocsc() csc.data = real(csc.data) csc.dtype.char = csc.data.dtype.char csc.ftype = _transtabl[csc.dtype.char] return csc
def _real(self): csc = self.tocsc() csc.data = real(csc.data) csc.dtype = csc.data.dtype csc.ftype = _transtabl[csc.dtype.char] return csc
1,090
def _imag(self): csc = self.tocsc() csc.data = imag(csc.data) csc.dtype.char = csc.data.dtype.char csc.ftype = _transtabl[csc.dtype.char] return csc
def _imag(self): csc = self.tocsc() csc.data = imag(csc.data) csc.dtype = csc.data.dtype csc.ftype = _transtabl[csc.dtype.char] return csc
1,091
def _check(self): M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind)
def _check(self): M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind)
1,092
def _check(self): M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind)
def _check(self): M, N = self.shape nnz = self.indptr[-1] nzmax = len(self.rowind)
1,093
def __mul__(self, other): """ Scalar, vector, or matrix multiplication """ if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data *= other new.dtype.char = new.data.dtype.char new.ftype = _transtabl[new.dtype.char] return new else: return self.dot(other) #else: # return TypeError, "unk...
def __mul__(self, other): """ Scalar, vector, or matrix multiplication """ if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data *= other new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: return self.dot(other) #else: # return TypeError, "unknown type ...
1,094
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = other * new.data new.dtype.char = new.data.dtype.char new.ftype = _transtabl[new.dtype.char] return new else: other = asarray(other) return self.transpose().dot(other.transpose()).transpose...
def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = other * new.data new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: other = asarray(other) return self.transpose().dot(other.transpose()).transpose()
1,095
def __pow__(self, other): """ Element-by-element power (unless other is a scalar, in which case return the matrix power.) """ if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = new.data ** other new.dtype.char = new.data.dtype.char new.ftype = _transtabl[new.dtype.char] return new e...
def __pow__(self, other): """ Element-by-element power (unless other is a scalar, in which case return the matrix power.) """ if isscalar(other) or (isdense(other) and rank(other)==0): new = self.copy() new.data = new.data ** other new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: ocs =...
1,096
def transpose(self, copy=False): M, N = self.shape new = csr_matrix((N, M), nzmax=self.nzmax, dtype=self.dtype.char) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
def transpose(self, copy=False): M, N = self.shape new = csr_matrix((N, M), nzmax=self.nzmax, dtype=self.dtype) if copy: new.data = self.data.copy() new.colind = self.rowind.copy() new.indptr = self.indptr.copy() else: new.data = self.data new.colind = self.rowind new.indptr = self.indptr new._check() return new
1,097
def conj(self, copy=False): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype.char) if copy: new.data = self.data.conj().copy() new.rowind = self.rowind.conj().copy() new.indptr = self.indptr.conj().copy() else: new.data = self.data.conj() new.rowind = self.rowind.conj() new.indptr = self.indptr.conj() ne...
def conj(self, copy=False): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) if copy: new.data = self.data.conj().copy() new.rowind = self.rowind.conj().copy() new.indptr = self.indptr.conj().copy() else: new.data = self.data.conj() new.rowind = self.rowind.conj() new.indptr = self.indptr.conj() new._ch...
1,098
def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype.char) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new
def copy(self): new = csc_matrix(self.shape, nzmax=self.nzmax, dtype=self.dtype) new.data = self.data.copy() new.rowind = self.rowind.copy() new.indptr = self.indptr.copy() new._check() return new
1,099