rem stringlengths 1 322k | add stringlengths 0 2.05M | context stringlengths 4 228k | meta stringlengths 156 215 |
|---|---|---|---|
Lsource = makelist(sourcebetweens,Nfactors+1) Bbtwnonsourcedims = ~source & Bbetweens Lbtwnonsourcedims = makelist(Bbtwnonsourcedims,Nfactors+1) btwnonsourcedims = (array(map(Bscols.index,Lbtwnonsourcedims))-1).tolist() | Lsource = makelist(sourcebetweens,Nfactors+1) Bbtwnonsourcedims = ~source & Bbetweens Lbtwnonsourcedims = makelist(Bbtwnonsourcedims,Nfactors+1) btwnonsourcedims = (array(map(Bscols.index,Lbtwnonsourcedims))-1).tolist() | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
sourceDMarray = DM[dindex] *1.0 for dim in btwnonsourcedims: if dim == len(DM[dindex].shape)-1: raise ValueError, "Crashing ... shouldn't ever collapse ACROSS variables" sourceDMarray = expand_dims(mean(sourceDMarray,dim),dim) | sourceDMarray = DM[dindex] *1.0 for dim in btwnonsourcedims: if dim == len(DM[dindex].shape)-1: raise ValueError, "Crashing ... shouldn't ever collapse ACROSS variables" sourceDMarray = expand_dims(mean(sourceDMarray,dim),dim) | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
sourceDNarray = apply_over_axes(hmean, DN[dindex],btwnonsourcedims) | sourceDNarray = apply_over_axes(hmean, DN[dindex],btwnonsourcedims) | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
variableNs = apply_over_axes(sum, sourceDNarray, range(len(sourceDMarray.shape)-1)) ga = apply_over_axes(sum, (sourceDMarray*sourceDNarray) / \ variableNs, range(len(sourceDMarray.shape)-1)) | variableNs = apply_over_axes(sum, sourceDNarray, range(len(sourceDMarray.shape)-1)) ga = apply_over_axes(sum, (sourceDMarray*sourceDNarray) / \ variableNs, range(len(sourceDMarray.shape)-1)) | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
if source == Nallsources-1: sourceDNarray = hmean(DN[dindex], range(len(sourceDMarray.shape)-1)) | if source == Nallsources-1: sourceDNarray = hmean(DN[dindex], range(len(sourceDMarray.shape)-1)) | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
sub_effects = ga *1.0 for subsource in range(3,source-2,2): | sub_effects = ga *1.0 for subsource in range(3,source-2,2): | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
if (propersubset(subsource-1,source-1) and (subsource-1)&Bwithins == (source-1)&Bwithins and (subsource-1) != (source-1)&Bwithins): sub_effects = (sub_effects + | if (propersubset(subsource-1,source-1) and (subsource-1)&Bwithins == (source-1)&Bwithins and (subsource-1) != (source-1)&Bwithins): sub_effects = (sub_effects + | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
effect = sourceDMarray - sub_effects | effect = sourceDMarray - sub_effects | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
alleffects.append(effect) alleffsources.append(source) | alleffects.append(effect) alleffsources.append(source) | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
SS = zeros((levels,levels),'f') SS = sum((effect**2 *sourceDNarray) * multiply.reduce(take(DM[dindex].shape,btwnonsourcedims)), range(len(sourceDMarray.shape)-1)) | SS = zeros((levels,levels),'f') SS = sum((effect**2 *sourceDNarray) * multiply.reduce(take(DM[dindex].shape,btwnonsourcedims)), range(len(sourceDMarray.shape)-1)) | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
SSlist.append(SS) SSsources.append(source) return SS | SSlist.append(SS) SSsources.append(source) return SS | def d_restrict_source(workd,subjslots,source): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
if len(workd.shape) == 1: levels = 1 else: levels = workd.shape[0] sserr = zeros((levels,levels),'f') for i in range(levels): for j in range(i,levels): ssval = add.reduce(workd[i]*workd[j]) sserr[i,j] = ssval sserr[j,i] = ssval return sserr | if len(workd.shape) == 1: levels = 1 else: levels = workd.shape[0] sserr = zeros((levels,levels),'f') for i in range(levels): for j in range(i,levels): ssval = add.reduce(workd[i]*workd[j]) sserr[i,j] = ssval sserr[j,i] = ssval return sserr | def multivar_sscalc(workd): | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
""" Subtract all cell means when within-subjects factors are present ... i.e., calculate full-model using a D-variable. """ sourcedims = makelist(Bbetweens,Nfactors+1) transidx = range(len(subjslots.shape))[1:] + [0] tsubjslots = transpose(subjslots,transidx) tworkd = transpose(workd) errors = 1.0 * tworkd if len(... | """ Subtract all cell means when within-subjects factors are present ... i.e., calculate full-model using a D-variable. """ sourcedims = makelist(Bbetweens,Nfactors+1) transidx = range(len(subjslots.shape))[1:] + [0] tsubjslots = transpose(subjslots,transidx) tworkd = transpose(workd) errors = 1.0 * tworkd if len(... | def subtr_cellmeans(workd,subjslots): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
while incr(idx,loopcap) != -1: mask = tsubjslots[idx] thisgroup = tworkd*mask[NewAxis,:] groupmns = mean(compress(mask,thisgroup),1) | while incr(idx,loopcap) != -1: mask = tsubjslots[idx] thisgroup = tworkd*mask[NewAxis,:] groupmns = mean(compress(mask,thisgroup),1) | def subtr_cellmeans(workd,subjslots): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
errors = errors - multiply.outer(groupmns,mask) return errors | errors = errors - multiply.outer(groupmns,mask) return errors | def subtr_cellmeans(workd,subjslots): """ | 3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/3bb739baad4fb4f21aa19b39fbb10f6aa5c1a041/stats.py |
if __name__ == "__main__": | def _testme(): | def speye(n, m = None, k = 0, dtype = 'd'): """ speye(n, m) returns a (n x m) matrix stored in CSC sparse matrix format, where the k-th diagonal is all ones, and everything else is zeros. """ diags = ones((1, n), dtype = dtype) return spdiags(diags, k, n, m) | 01b070b28212b3a1a02ca1e68c2a9b52e29c4443 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/01b070b28212b3a1a02ca1e68c2a9b52e29c4443/sparse.py |
_endprint(x, flag, fval, maxfun, tol, disp) | _endprint(x, flag, fval, maxfun, xtol, disp) | def fminbound(func, x1, x2, args=(), xtol=1e-5, maxfun=500, full_output=0, disp=1): """Bounded minimization for scalar functions. Description: Finds a local minimizer of the scalar function func in the interval x1 < xopt < x2 using Brent's method. (See brent for auto-bracketing). Inputs: func -- the function to be... | 57ee28ebf2c56ff23c90606b449d465aad5b8402 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/57ee28ebf2c56ff23c90606b449d465aad5b8402/optimize.py |
raise ValuError, "Bracketing interval must be length 2 or 3 sequence." | raise ValueError, "Bracketing interval must be length 2 or 3 sequence." | def brent(func, args=(), brack=None, tol=1.48e-8, full_output=0, maxiter=500): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If... | 57ee28ebf2c56ff23c90606b449d465aad5b8402 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/57ee28ebf2c56ff23c90606b449d465aad5b8402/optimize.py |
raise ValuError, "Bracketing interval must be length 2 or 3 sequence." | raise ValueError, "Bracketing interval must be length 2 or 3 sequence." | def golden(func, args=(), brack=None, tol=_epsilon, full_output=0): """ Given a function of one-variable and a possible bracketing interval, return the minimum of the function isolated to a fractional precision of tol. A bracketing interval is a triple (a,b,c) where (a<b<c) and func(b) < func(a),func(c). If bracket is... | 57ee28ebf2c56ff23c90606b449d465aad5b8402 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/57ee28ebf2c56ff23c90606b449d465aad5b8402/optimize.py |
raise RunTimeError, "Too many iterations." | raise RuntimeError, "Too many iterations." | def bracket(func, xa=0.0, xb=1.0, args=(), grow_limit=110.0): """Given a function and distinct initial points, search in the downhill direction (as defined by the initital points) and return new points xa, xb, xc that bracket the minimum of the function: f(xa) > f(xb) < f(xc) """ _gold = 1.618034 _verysmall_num = 1e-21... | 57ee28ebf2c56ff23c90606b449d465aad5b8402 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/57ee28ebf2c56ff23c90606b449d465aad5b8402/optimize.py |
(-10,1):0L, (10,-1):0L, (-10,-3):0L,(10,11),0L} | (-10,1):0L, (10,-1):0L, (-10,-3):0L,(10,11):0L} | def check_exact(self): resdict = {(10,2):45L, (10,5):252L, (1000,20):339482811302457603895512614793686020778700L, (1000,975):47641862536236518640933948075167736642053976275040L, (-10,1):0L, (10,-1):0L, (-10,-3):0L,(10,11),0L} for key in resdict.keys(): assert_equal(comb(key[0],key[1],exact=1),resdict[key]) | 5724580f929252a402a0f94ec5f44c7dad72ff5a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/5724580f929252a402a0f94ec5f44c7dad72ff5a/test_common.py |
def getH(self): return self.transpose().conj() # csc = self.tocsc() # new = csc.transpose() # new.data = conj(new.data) # return new | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | ||
except (AttributeError, TypeError): try: return self.matvec(asarray(other)) except: raise TypeError, "x.dot(y): y must be matrix, vector, or seq" except ValueError: K2 = other.shape[0] N = 1 if N == 1: | elif len(other.shape) == 1: K2, N = other.shape[0], 1 else: raise ValueError, "could not interpret dimensions" if N == 1 or K2 == 1: | def dot(self, other): """ A generic interface for matrix-matrix or matrix-vector multiplication. Returns A.transpose().conj() * other or A.transpose() * other. """ M, K1 = self.shape try: K2, N = other.shape except (AttributeError, TypeError): # Not sparse or dense. Interpret it as a sequence. try: return self.matvec... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def save( self, file_name, format = '%d %d %f\n' ): | def save(self, file_name, format = '%d %d %f\n'): | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
fd = open( file_name, 'w' ) | fd = open(file_name, 'w') | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) | fd.write('%d %d\n' % self.shape) fd.write('%d\n' % self.size) for ii in xrange(self.size): ir, ic = self.rowcol(ii) data = self.getdata(ii) fd.write(format % (ir, ic, data)) | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
with a dense matrix d | with a dense array or matrix d | def save( self, file_name, format = '%d %d %f\n' ): try: fd = open( file_name, 'w' ) except Exception, e: raise e, file_name fd.write( '%d %d\n' % self.shape ) fd.write( '%d\n' % self.size ) for ii in xrange( self.size ): ir, ic = self.rowcol( ii ) data = self.getdata( ii ) fd.write( format % (ir, ic, data) ) fd.close... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): | def __init__(self, arg1, dims=None, nzmax=100, dtype='d', copy=False): | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | ||
s = asarray(arg1) | s = arg1 | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
dtype = s.dtype.char func = getattr(sparsetools, _transtabl[dtype]+'fulltocsc') | dtype = s.dtype func = getattr(sparsetools, _transtabl[dtype.char]+'fulltocsc') | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
temp = coo_matrix( s, ij, dims=dims, nzmax=nzmax, \ dtype=dtype).tocsc() self.shape = temp.shape self.data = temp.data self.rowind = temp.rowind self.indptr = temp.indptr except: | except (AssertionError, TypeError, ValueError): | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSC format if rank(arg1) == 2: s = asarray(arg1) if s.dtype.char not in 'fdFD': # Use a double array as the source (but leave it alone) s = s*1.0 if (rank(s) == 2): ... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
other = asarray(other) return self.transpose().dot(other.transpose()).transpose() | try: tr = other.transpose() except AttributeError: tr = asarray(other).transpose() return self.transpose().dot(tr).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() | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" | def matvec(self, other): if isdense(other): if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'cscmux') y = func(self.data, self.rowind, self.indptr, other, self.shape[0]) return y elif isspmatrix(other): raise NotImplementedError, "use... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | |
if (rank(other) != 1) or (len(other) != self.shape[0]): raise ValueError, "dimension mismatch" | def rmatvec(self, other, conjugate=True): if isdense(other): if (rank(other) != 1) or (len(other) != self.shape[0]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'csrmux') if conjugate: cd = conj(self.data) else: cd = self.data y = func(cd, self.rowind, self.indptr, other) return y elif... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | |
def matmat(self, other): if isspmatrix(other): M, K1 = self.shape K2, N = other.shape if (K1 != K2): raise ValueError, "shape mismatch error" a, rowa, ptra = self.data, self.rowind, self.indptr if isinstance(other, csr_matrix): other._check() dtypechar = _coerce_rules[(self.dtype.char, other.dtype.char)] ftype = _trans... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | ||
raise KeyError, "index out of bounds" | raise IndexError, "index out of bounds" | def __getitem__(self, key): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscgetel') M, N = self.shape if not (0<=row<M) or not (0<=col<N): raise KeyError, "index out of bounds" ind, val = func(self.data, self.rowind, self.indptr, row, col) return val #elif isins... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
raise KeyError, "key out of bounds" | raise IndexError, "index out of bounds" | def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise IndexError, "index out of bounds" if (col >= N): self.indptr = res... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
with a dense matrix d | with a dense array or matrix d | 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 | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): | def __init__(self, arg1, dims=None, nzmax=100, dtype='d', copy=False): | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | ||
s = asarray(arg1) | s = arg1 | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
ijnew = ij.copy() ijnew[:, 0] = ij[:, 1] ijnew[:, 1] = ij[:, 0] temp = coo_matrix(s, ijnew, dims=dims, nzmax=nzmax, dtype=dtype).tocsr() self.shape = temp.shape self.data = temp.data self.colind = temp.colind self.indptr = temp.indptr except: | except (AssertionError, TypeError, ValueError, AttributeError): | def __init__(self, arg1, dims=(None,None), nzmax=100, dtype='d', copy=False): spmatrix.__init__(self) if isdense(arg1): # Convert the dense matrix arg1 to CSR format if rank(arg1) == 2: s = asarray(arg1) ocsc = csc_matrix(transpose(s)) self.colind = ocsc.rowind self.indptr = ocsc.indptr self.data = ocsc.data self.shape... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
raise NotImplementedError, 'adding a scalar to a sparse matrix ' \ | raise NotImplementedError, 'adding a scalar to a CSR matrix ' \ | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): # Now we would add this scalar to every element. raise NotImplementedError, 'adding a scalar to a sparse matrix ' \ 'is not yet supported' elif isspmatrix(other): ocs = other.tocsr() if (ocs.shape ... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
other = asarray(other) return self.transpose().dot(other.transpose()).transpose() | try: tr = other.transpose() except AttributeError: tr = asarray(other).transpose() return self.transpose().dot(tr).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 # allows type conversion new.dtype = new.data.dtype new.ftype = _transtabl[new.dtype.char] return new else: other = asarray(other) return self.transpose().dot(other... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'csrmux') y = func(self.data, self.colind, self.indptr, other) return y | if isdense(other): func = getattr(sparsetools, self.ftype+'csrmux') y = func(self.data, self.colind, self.indptr, other) return y else: raise TypeError, "need a dense vector" | def matvec(self, other): if (rank(other) != 1) or (len(other) != self.shape[1]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'csrmux') y = func(self.data, self.colind, self.indptr, other) return y | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
if (rank(other) != 1) or (len(other) != self.shape[0]): raise ValueError, "dimension mismatch" | def rmatvec(self, other, conjugate=True): if (rank(other) != 1) or (len(other) != self.shape[0]): raise ValueError, "dimension mismatch" func = getattr(sparsetools, self.ftype+'cscmux') if conjugate: cd = conj(self.data) else: cd = self.data y = func(cd, self.colind, self.indptr, other, self.shape[1]) return y | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | |
raise KeyError, "index out of bounds" | raise IndexError, "index out of bounds" | def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise KeyError, "index out of bounds" if (row >= M): self.indptr = resiz... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
raise KeyError, "key out of bounds" | raise IndexError, "index out of bounds" | def __setitem__(self, key, val): if isinstance(key, types.TupleType): row = key[0] col = key[1] func = getattr(sparsetools, self.ftype+'cscsetel') M, N = self.shape if (row < 0): row = M + row if (col < 0): col = N + col if (row < 0) or (col < 0): raise KeyError, "index out of bounds" if (row >= M): self.indptr = resiz... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
""" A dictionary of keys based matrix. This is relatively efficient for constructing sparse matrices for conversion to other sparse matrix types. It does type checking on input by default. To disable this type checking and speed up element accesses slightly, set self._validate to False. | """ A dictionary of keys based matrix. This is an efficient structure for constructing sparse matrices for conversion to other sparse matrix types. | # def csc_cmp(x, y): | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def __init__(self, A=None): | def __init__(self, A=None, dtype='d'): | def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
A = asarray(A) | def __init__(self, A=None): """ Create a new dictionary-of-keys sparse matrix. An optional argument A is accepted, which initializes the dok_matrix with it. This can be a tuple of dimensions (m, n) or a (dense) array to copy. """ dict.__init__(self) spmatrix.__init__(self) self.shape = (0, 0) # If _validate is True, e... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new.shape = self.shape for key in other.keys(): | for key in other: | def __add__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self.... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | ||
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for key in other.keys(): | for key in other: | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
else: | elif isdense(other): | def __radd__(self, other): # First check if argument is a scalar if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Add this scalar to every element. M, N = self.shape for i in range(M): for j in range(N): aij = self.get((i, j), 0) + other if aij != 0: new[i, j] = aij #new.dtype.char = self... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() for key in self.keys(): | new = dok_matrix(self.shape, dtype=self.dtype) for key in self: | def __neg__(self): new = dok_matrix() for key in self.keys(): new[key] = -self[key] return new | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def __mul__(self, other): # self * other if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = val * other #new.dtype.char = self.dtype.char return new else: return self.dot(other) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for (key, val) in self.items(): | for (key, val) in self.iteritems(): | def __mul__(self, other): # self * other if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = val * other #new.dtype.char = self.dtype.char return new else: return self.dot(other) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for (key, val) in self.items(): | for (key, val) in self.iteritems(): | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
other = asarray(other) return self.transpose().dot(other.transpose()).transpose() | try: tr = other.transpose() except AttributeError: tr = asarray(other).transpose() return self.transpose().dot(tr).transpose() | def __rmul__(self, other): # other * self if isscalar(other) or (isdense(other) and rank(other)==0): new = dok_matrix() # Multiply this scalar by every element. for (key, val) in self.items(): new[key] = other * val #new.dtype.char = self.dtype.char return new else: other = asarray(other) return self.transpose... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
newshape = (self.shape[1], self.shape[0]) new = dok_matrix(newshape) for key in self.keys(): new[key[1], key[0]] = self[key] | m, n = self.shape new = dok_matrix((n, m), dtype=self.dtype) for key, value in self.iteritems(): new[key[1], key[0]] = value | def transpose(self): """ Return the transpose """ newshape = (self.shape[1], self.shape[0]) new = dok_matrix(newshape) for key in self.keys(): new[key[1], key[0]] = self[key] return new | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() for key in self.keys(): new[key[1], key[0]] = conj(self[key]) | m, n = self.shape new = dok_matrix((n, m), dtype=self.dtype) for key, value in self.iteritems(): new[key[1], key[0]] = conj(value) | def conjtransp(self): """ Return the conjugate transpose """ new = dok_matrix() for key in self.keys(): new[key[1], key[0]] = conj(self[key]) return new | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def copy(self): new = dok_matrix() new.update(self) new.shape = self.shape return new | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
new = dok_matrix() | new = dok_matrix(self.shape, dtype=self.dtype) | def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newk... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for key in self.keys(): | for key in self: | def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newk... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for key in self.keys(): | for key in self: | def take(self, cols_or_rows, columns=1): # Extract columns or rows as indictated from matrix # assume cols_or_rows is sorted new = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: # columns for key in self.keys(): num = searchsorted(cols_or_rows, key[1]) if num < N: newkey = (key[0], num) new[newk... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for key in self.keys(): | for key in self: | def split(self, cols_or_rows, columns=1): # similar to take but returns two array, the extracted # columns plus the resulting array # assumes cols_or_rows is sorted base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: for key in self.keys(): num = searchsorted(cols_or_rows,... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for key in self.keys(): | for key in self: | def split(self, cols_or_rows, columns=1): # similar to take but returns two array, the extracted # columns plus the resulting array # assumes cols_or_rows is sorted base = dok_matrix() ext = dok_matrix() indx = int((columns == 1)) N = len(cols_or_rows) if indx: for key in self.keys(): num = searchsorted(cols_or_rows,... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
for key in self.keys(): | for key in self: | def matvec(self, other): other = asarray(other) if other.shape[0] != self.shape[1]: raise ValueError, "dimensions do not match" new = [0]*self.shape[0] for key in self.keys(): new[int(key[0])] += self[key] * other[int(key[1]), ...] return array(new) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
if other.shape[-1] != self.shape[0]: raise ValueError, "dimensions do not match" new = [0]*self.shape[1] for key in self.keys(): new[int(key[1])] += other[..., int(key[0])] * conj(self[key]) return array(new) | if other.shape[-1] != self.shape[0]: raise ValueError, "dimensions do not match" new = [0]*self.shape[1] for key in self: new[int(key[1])] += other[..., int(key[0])] * conj(self[key]) return array(new) | def rmatvec(self, other, conjugate=True): other = asarray(other) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
data = [0]*nzmax colind = [0]*nzmax | data = zeros(nzmax, dtype=self.dtype) colind = zeros(nzmax, dtype=self.dtype) | def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
row_ptr = [nnz]*(self.shape[0]+1) | row_ptr = empty(self.shape[0]+1, dtype=int) row_ptr[:] = nnz | def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
row_ptr[current_row+1:ikey0+1] = [k]*N | row_ptr[current_row+1:ikey0+1] = k | def tocsr(self, nzmax=None): """ Return Compressed Sparse Row format arrays for this matrix """ keys = self.keys() keys.sort() nnz = len(keys) nzmax = max(nnz, nzmax) data = [0]*nzmax colind = [0]*nzmax # Empty rows will leave row_ptr dangling. We assign row_ptr[i] # for each empty row i to point off the end. Is this... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
keys = [(k[1], k[0]) for k in self.keys()] | keys = [(k[1], k[0]) for k in self] | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
data = [0]*nzmax rowind = [0]*nzmax | data = zeros(nzmax, dtype=self.dtype) rowind = zeros(nzmax, dtype=self.dtype) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
col_ptr = [nnz]*(self.shape[1]+1) | col_ptr = empty(self.shape[1]+1) col_ptr[:] = nnz | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
col_ptr[current_col+1:ikey1+1] = [k]*N | col_ptr[current_col+1:ikey1+1] = k | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
data = array(data) rowind = array(rowind) col_ptr = array(col_ptr) | def tocsc(self, nzmax=None): """ Return Compressed Sparse Column format arrays for this matrix """ # Sort based on columns # This works, but is very slow for matrices with many non-zero # elements (requiring a function call for every element) #keys.sort(csc_cmp) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py | |
for key in self.keys(): | for key in self: | def todense(self, dtype=None): if dtype is None: dtype = 'd' new = zeros(self.shape, dtype=dtype) for key in self.keys(): ikey0 = int(key[0]) ikey1 = int(key[1]) new[ikey0, ikey1] = self[key] if amax(ravel(abs(new.imag))) == 0: new = new.real return new | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
if isdense( ij_in ) and (ij_in.shape[1] == 2): | if isdense(ij_in) and (ij_in.shape[1] == 2): | def __init__(self, obj, ij_in, dims=None, nzmax=None, dtype=None): spmatrix.__init__(self) try: # Assume the first calling convention # assert len(ij) == 2 if len(ij_in) != 2: if isdense( ij_in ) and (ij_in.shape[1] == 2): ij = (ij_in[:,0], ij_in[:,1]) else: raise AssertionError else: ij = ij_in if dims is N... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def isspmatrix_csr( x ): | def isspmatrix_csr(x): | def isspmatrix_csr( x ): return isinstance(x, csr_matrix) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def isspmatrix_csc( x ): | def isspmatrix_csc(x): | def isspmatrix_csc( x ): return isinstance(x, csc_matrix) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def isspmatrix_dok( x ): | def isspmatrix_dok(x): | def isspmatrix_dok( x ): return isinstance(x, dok_matrix) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def isspmatrix_dod( x ): | def isspmatrix_dod(x): | def isspmatrix_dod( x ): return isinstance(x, dod_matrix) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def isspmatrix_lnk( x ): | def isspmatrix_lnk(x): | def isspmatrix_lnk( x ): return isinstance(x, lnk_matrix) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
def isspmatrix_coo( x ): | def isspmatrix_coo(x): | def isspmatrix_coo( x ): return isinstance(x, coo_matrix) | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
"""Return a sparse matrix in CSR format given its diagonals. | """Return a sparse matrix in CSC format given its diagonals. | def spdiags(diags, offsets, M, N): """Return a sparse matrix in CSR format given its diagonals. B = spdiags(diags, offsets, M, N) Inputs: diags -- rows contain diagonal values offsets -- diagonals to set (0 is main) M, N -- sparse matrix returned is M X N """ diags = array(transpose(diags), copy=True) if diags.d... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
diagfunc = eval('sparsetools.'+_transtabl[mtype]+'diatocsr') | diagfunc = eval('sparsetools.'+_transtabl[mtype]+'diatocsc') | def spdiags(diags, offsets, M, N): """Return a sparse matrix in CSR format given its diagonals. B = spdiags(diags, offsets, M, N) Inputs: diags -- rows contain diagonal values offsets -- diagonals to set (0 is main) M, N -- sparse matrix returned is M X N """ diags = array(transpose(diags), copy=True) if diags.d... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
if hasattr(A, 'tocsc') and not isspmatrix_csr( A ): | if hasattr(A, 'tocsc') and not isspmatrix_csr(A): | def solve(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, N = A.s... | cc9a850083c66543ac7901fd68022fbe73610704 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/cc9a850083c66543ac7901fd68022fbe73610704/sparse.py |
return 1.0/(1+exp(-1.0/b*norm.ppf(q)-a)) | return 1.0/(1+exp(-1.0/b*(norm.ppf(q)-a))) | def _ppf(self, q, a, b): return 1.0/(1+exp(-1.0/b*norm.ppf(q)-a)) | 05b92c52116db8f043e416d3056416410d288665 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/05b92c52116db8f043e416d3056416410d288665/distributions.py |
if isinstance(system, lti): | if isinstance(system, lti): | def lsim2(system, U, T, X0=None): """Simulate output of a continuous-time linear system, using ODE solver. Inputs: system -- an instance of the LTI class or a tuple describing the system. The following gives the number of elements in the tuple and the interpretation. 2 (num, den) 3 (zeros, poles, gain) 4 (A, B, C, D... | e8fcc876d2f5bd4ab71bfa836f3d3ce06de5b617 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/e8fcc876d2f5bd4ab71bfa836f3d3ce06de5b617/ltisys.py |
yout -- impulse response of system. | yout -- impulse response of system (except possible singularities at 0). | def impulse(system, X0=None, T=None, N=None): """Impulse response of continuous-time system. Inputs: system -- an instance of the LTI class or a tuple with 2, 3, or 4 elements representing (num, den), (zero, pole, gain), or (A, B, C, D) representation of the system. X0 -- (optional, default = 0) inital state-vector. ... | e8fcc876d2f5bd4ab71bfa836f3d3ce06de5b617 /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/e8fcc876d2f5bd4ab71bfa836f3d3ce06de5b617/ltisys.py |
buffer=raw_tag[4:]) | buffer=raw_tag[4:4+byte_count]) | def read_element(self, copy=True): raw_tag = self.mat_stream.read(8) tag = ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) mdtype = tag['mdtype'] byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: raise ValueError, 'Too many bytes for sde format' mdtype = mdtype &... | 480afd5e75d2805992c5f44fabda71fe19a0a93a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/480afd5e75d2805992c5f44fabda71fe19a0a93a/mio5.py |
return self.current_getter().get_array() | return self.current_getter(byte_count).get_array() | def read_element(self, copy=True): raw_tag = self.mat_stream.read(8) tag = ndarray(shape=(), dtype=self.dtypes['tag_full'], buffer = raw_tag) mdtype = tag['mdtype'] byte_count = mdtype >> 16 if byte_count: # small data element format if byte_count > 4: raise ValueError, 'Too many bytes for sde format' mdtype = mdtype &... | 480afd5e75d2805992c5f44fabda71fe19a0a93a /local1/tlutelli/issta_data/temp/all_python//python/2006_temp/2006/12971/480afd5e75d2805992c5f44fabda71fe19a0a93a/mio5.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.