本文整理汇总了Python中numeric.broadcast函数的典型用法代码示例。如果您正苦于以下问题:Python broadcast函数的具体用法?Python broadcast怎么用?Python broadcast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了broadcast函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __radd__
def __radd__(self, other):
b = broadcast(other, self)
outitem = b.iters[0].base.itemsize + \
b.iters[1].base.itemsize
result = chararray(b.shape, outitem, self.dtype is unicode_)
res = result.flat
for k, val in enumerate(b):
res[k] = (val[0] + val[1])
return result
开发者ID:radical-software,项目名称:radicalspam,代码行数:9,代码来源:defchararray.py
示例2: __mul__
def __mul__(self, other):
b = broadcast(self, other)
arr = b.iters[1].base
if not issubclass(arr.dtype.type, integer):
raise ValueError, "Can only multiply by integers"
outitem = b.iters[0].base.itemsize * arr.max()
result = chararray(b.shape, outitem, self.dtype is unicode_)
res = result.flat
for k, val in enumerate(b):
res[k] = val[0]*val[1]
return result
开发者ID:radical-software,项目名称:radicalspam,代码行数:11,代码来源:defchararray.py
示例3: __mod__
def __mod__(self, other):
b = broadcast(self, other)
res = [None]*b.size
maxsize = -1
for k,val in enumerate(b):
newval = val[0] % val[1]
maxsize = max(len(newval), maxsize)
res[k] = newval
newarr = chararray(b.shape, maxsize, self.dtype is unicode_)
newarr[:] = res
return newarr
开发者ID:radical-software,项目名称:radicalspam,代码行数:11,代码来源:defchararray.py
示例4: startswith
def startswith(self, prefix, start=None, end=None):
return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例5: strip
def strip(self, chars=None):
return self._generalmethod('strip', broadcast(self, chars))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例6: split
def split(self, sep=None, maxsplit=None):
return self._typedmethod('split', broadcast(self, sep, maxsplit), object)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例7: splitlines
def splitlines(self, keepends=None):
return self._typedmethod('splitlines', broadcast(self, keepends), object)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例8: center
def center(self, width):
return self._generalmethod('center', broadcast(self, width))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例9: rindex
def rindex(self, sub, start=None, end=None):
return self._typedmethod('rindex', broadcast(self, sub, start, end), int)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例10: join
def join(self, seq):
return self._generalmethod('join', broadcast(self, seq))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例11: rjust
def rjust(self, width, fillchar=' '):
return self._generalmethod('rjust',
broadcast(self, width, fillchar))
开发者ID:radical-software,项目名称:radicalspam,代码行数:3,代码来源:defchararray.py
示例12: expandtabs
def expandtabs(self, tabsize=None):
return self._generalmethod('endswith', broadcast(self, tabsize))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例13: find
def find(self, sub, start=None, end=None):
return self._typedmethod('find', broadcast(self, sub, start, end), int)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例14: endswith
def endswith(self, suffix, start=None, end=None):
return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例15: encode
def encode(self,encoding=None,errors=None):
return self._generalmethod('encode', broadcast(self, encoding, errors))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例16: count
def count(self, sub, start=None, end=None):
return self._typedmethod('count', broadcast(self, sub, start, end), int)
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例17: translate
def translate(self, table, deletechars=None):
if self.dtype is unicode_:
return self._generalmethod('translate', broadcast(self, table))
else:
return self._generalmethod('translate', broadcast(self, table, deletechars))
开发者ID:radical-software,项目名称:radicalspam,代码行数:5,代码来源:defchararray.py
示例18: zfill
def zfill(self, width):
return self._generalmethod('zfill', broadcast(self, width))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例19: replace
def replace(self, old, new, count=None):
return self._generalmethod('replace', broadcast(self, old, new, count))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
示例20: lstrip
def lstrip(self, chars):
return self._generalmethod('lstrip', broadcast(self, chars))
开发者ID:radical-software,项目名称:radicalspam,代码行数:2,代码来源:defchararray.py
注:本文中的numeric.broadcast函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论