当前位置: 首页>>代码示例>>Python>>正文


Python six.iteritems函数代码示例

本文整理汇总了Python中scipy.lib.six.iteritems函数的典型用法代码示例。如果您正苦于以下问题:Python iteritems函数的具体用法?Python iteritems怎么用?Python iteritems使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了iteritems函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _mul_scalar

 def _mul_scalar(self, other):
     res_dtype = upcast_scalar(self.dtype, other)
     # Multiply this scalar by every element.
     new = dok_matrix(self.shape, dtype=res_dtype)
     for (key, val) in iteritems(self):
         new[key] = val * other
     return new
开发者ID:ChadFulton,项目名称:scipy,代码行数:7,代码来源:dok.py

示例2: conjtransp

 def conjtransp(self):
     """ Return the conjugate transpose
     """
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     for key, value in iteritems(self):
         new[key[1], key[0]] = np.conj(value)
     return new
开发者ID:ChadFulton,项目名称:scipy,代码行数:8,代码来源:dok.py

示例3: transpose

 def transpose(self):
     """ Return the transpose
     """
     M, N = self.shape
     new = dok_matrix((N, M), dtype=self.dtype)
     for key, value in iteritems(self):
         new[key[1], key[0]] = value
     return new
开发者ID:ChadFulton,项目名称:scipy,代码行数:8,代码来源:dok.py

示例4: __itruediv__

 def __itruediv__(self, other):
     if isscalarlike(other):
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             self[key] = val / other
         return self
     else:
         return NotImplemented
开发者ID:ChadFulton,项目名称:scipy,代码行数:8,代码来源:dok.py

示例5: _mul_multivector

 def _mul_multivector(self, other):
     # matrix * multivector
     M,N = self.shape
     n_vecs = other.shape[1]  # number of column vectors
     result = np.zeros((M,n_vecs), dtype=upcast(self.dtype,other.dtype))
     for (i,j),v in iteritems(self):
         result[i,:] += v * other[j,:]
     return result
开发者ID:ChadFulton,项目名称:scipy,代码行数:8,代码来源:dok.py

示例6: __imul__

 def __imul__(self, other):
     if isscalarlike(other):
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             self[key] = val * other
         # new.dtype.char = self.dtype.char
         return self
     else:
         return NotImplemented
开发者ID:ChadFulton,项目名称:scipy,代码行数:9,代码来源:dok.py

示例7: __str__

 def __str__(self):
     ss = "%s\n" % self.__class__
     for key, val in iteritems(self.__dict__):
         if (issubclass(self.__dict__[key].__class__, Struct)):
             ss += "  %s:\n    %s\n" % (key, self.__dict__[key].__class__)
         else:
             aux = "\n" + str(val)
             aux = aux.replace("\n", "\n    ")
             ss += "  %s:\n%s\n" % (key, aux[1:])
     return(ss.rstrip())
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:10,代码来源:umfpack.py

示例8: __truediv__

 def __truediv__(self, other):
     if isscalarlike(other):
         new = dok_matrix(self.shape, dtype=self.dtype)
         # Multiply this scalar by every element.
         for (key, val) in iteritems(self):
             new[key] = val / other
         # new.dtype.char = self.dtype.char
         return new
     else:
         return self.tocsr() / other
开发者ID:alfonsodiecko,项目名称:PYTHON_DIST,代码行数:10,代码来源:dok.py

示例9: dok_lt

def dok_lt(self, other):
    """
    Element-wise greater than
    """
    # First, store all the non-trivial elements
    ret = sp.dok_matrix(self, dtype = bool, copy = True)
    for (key, val) in iteritems(self):
        ret[key] = val < other
    
    # TODO: dok_matrix by default returns 0.0 for unknown keys
    # this should be replaced by either False for bool arrays 
    # OR, better, a default setting, either True or False
    return ret
开发者ID:jeffrey-hokanson,项目名称:IMD,代码行数:13,代码来源:imd.py

示例10: _mul_vector

 def _mul_vector(self, other):
     # matrix * vector
     result = np.zeros(self.shape[0], dtype=upcast(self.dtype,other.dtype))
     for (i,j),v in iteritems(self):
         result[i] += v * other[j]
     return result
开发者ID:ChadFulton,项目名称:scipy,代码行数:6,代码来源:dok.py

示例11: rankdata

x = data['ENTRIESn_hourly'][data['rain'] == 0]
y = data['ENTRIESn_hourly'][data['rain'] == 1]


# As there was an issue with the scipy.stats.mannwhitneyu(y,x) which gave a nan p-value, I had to copy/paste the
# calculating functions instead of using directly scipy.stats.mannwhitneyu(x,y)

use_continuity = True
x = ma.asarray(x).compressed().view(ndarray)
y = ma.asarray(y).compressed().view(ndarray)
ranks = rankdata(np.concatenate([x,y]))
(nx, ny) = (len(x), len(y))
nt = nx + ny
U = ranks[:nx].sum() - nx*(nx+1)/2.
U = max(U, nx*ny - U)
u = nx*ny - U
#
mu = (nx*ny)/2.
sigsq = (nt**3 - nt)/12.
ties = count_tied_groups(ranks)
sigsq -= np.sum(v*(k**3-k) for (k,v) in iteritems(ties))/12.
sigsq *= nx*ny/float(nt*(nt-1))

if use_continuity:
    z = (U - 1/2. - mu) / ma.sqrt(sigsq)
else:
    z = (U - mu) / ma.sqrt(sigsq)
prob = special.erfc(abs(z)/np.sqrt(2))

print "p-value : " + str(prob)
开发者ID:kaltera,项目名称:NYC-Subway-Subway-Dataset-Analysis,代码行数:30,代码来源:2+-+Linear+Regression.py


注:本文中的scipy.lib.six.iteritems函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。