本文整理汇总了Python中numeric.broadcast函数的典型用法代码示例。如果您正苦于以下问题:Python broadcast函数的具体用法?Python broadcast怎么用?Python broadcast使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了broadcast函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
示例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
示例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
示例4: startswith
def startswith(self, prefix, start=None, end=None):
return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)
示例5: strip
def strip(self, chars=None):
return self._generalmethod('strip', broadcast(self, chars))
示例6: split
def split(self, sep=None, maxsplit=None):
return self._typedmethod('split', broadcast(self, sep, maxsplit), object)
示例7: splitlines
def splitlines(self, keepends=None):
return self._typedmethod('splitlines', broadcast(self, keepends), object)
示例8: center
def center(self, width):
return self._generalmethod('center', broadcast(self, width))
示例9: rindex
def rindex(self, sub, start=None, end=None):
return self._typedmethod('rindex', broadcast(self, sub, start, end), int)
示例10: join
def join(self, seq):
return self._generalmethod('join', broadcast(self, seq))
示例11: rjust
def rjust(self, width, fillchar=' '):
return self._generalmethod('rjust',
broadcast(self, width, fillchar))
示例12: expandtabs
def expandtabs(self, tabsize=None):
return self._generalmethod('endswith', broadcast(self, tabsize))
示例13: find
def find(self, sub, start=None, end=None):
return self._typedmethod('find', broadcast(self, sub, start, end), int)
示例14: endswith
def endswith(self, suffix, start=None, end=None):
return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)
示例15: encode
def encode(self,encoding=None,errors=None):
return self._generalmethod('encode', broadcast(self, encoding, errors))