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
0
 def __add__(self, other):
     b = broadcast(self, other)
     arr = b.iters[1].base
     outitem = self.itemsize + arr.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
示例#3
0
 def __rmul__(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
示例#4
0
 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
 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
 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
示例#7
0
 def lstrip(self, chars):
     return self._generalmethod('lstrip', broadcast(self, chars))
示例#8
0
 def find(self, sub, start=None, end=None):
     return self._typedmethod('find', broadcast(self, sub, start, end), int)
示例#9
0
 def endswith(self, suffix, start=None, end=None):
     return self._typedmethod('endswith', broadcast(self, suffix, start,
                                                    end), bool)
示例#10
0
 def count(self, sub, start=None, end=None):
     return self._typedmethod('count', broadcast(self, sub, start, end),
                              int)
示例#11
0
 def rjust(self, width):
     return self._generalmethod('rjust', broadcast(self, width))
 def encode(self,encoding=None,errors=None):
     return self._generalmethod('encode', broadcast(self, encoding, errors))
示例#13
0
 def strip(self, chars=None):
     return self._generalmethod('strip', broadcast(self, chars))
 def replace(self, old, new, count=None):
     return self._generalmethod('replace', broadcast(self, old, new, count))
 def lstrip(self, chars):
     return self._generalmethod('lstrip', broadcast(self, chars))
 def join(self, seq):
     return self._generalmethod('join', broadcast(self, seq))
 def find(self, sub, start=None, end=None):
     return self._typedmethod('find', broadcast(self, sub, start, end), int)
 def expandtabs(self, tabsize=None):
     return self._generalmethod('endswith', broadcast(self, tabsize))
 def endswith(self, suffix, start=None, end=None):
     return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)
示例#20
0
 def rindex(self, sub, start=None, end=None):
     return self._typedmethod('rindex', broadcast(self, sub, start, end),
                              int)
示例#21
0
 def splitlines(self, keepends=None):
     return self._typedmethod('splitlines', broadcast(self, keepends),
                              object)
 def rindex(self, sub, start=None, end=None):
     return self._typedmethod('rindex', broadcast(self, sub, start, end), int)
示例#23
0
 def zfill(self, width):
     return self._generalmethod('zfill', broadcast(self, width))
 def split(self, sep=None, maxsplit=None):
     return self._typedmethod('split', broadcast(self, sep, maxsplit), object)
示例#25
0
 def rjust(self, width, fillchar=' '):
     return self._generalmethod('rjust',
                                broadcast(self, width, fillchar))
 def splitlines(self, keepends=None):
     return self._typedmethod('splitlines', broadcast(self, keepends), object)
示例#27
0
 def center(self, width):
     return self._generalmethod('center', broadcast(self, width))
 def startswith(self, prefix, start=None, end=None):
     return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)
示例#29
0
 def encode(self, encoding=None, errors=None):
     return self._generalmethod('encode', broadcast(self, encoding, errors))
 def strip(self, chars=None):
     return self._generalmethod('strip', broadcast(self, chars))
示例#31
0
 def expandtabs(self, tabsize=None):
     return self._generalmethod('endswith', broadcast(self, tabsize))
 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))
示例#33
0
 def join(self, seq):
     return self._generalmethod('join', broadcast(self, seq))
 def zfill(self, width):
     return self._generalmethod('zfill', broadcast(self, width))
示例#35
0
 def replace(self, old, new, count=None):
     return self._generalmethod('replace', broadcast(self, old, new, count))
 def rjust(self, width, fillchar=' '):
     return self._generalmethod('rjust',
                                broadcast(self, width, fillchar))
示例#37
0
 def split(self, sep=None, maxsplit=None):
     return self._typedmethod('split', broadcast(self, sep, maxsplit),
                              object)
 def center(self, width, fillchar=' '):
     return self._generalmethod('center',
                                broadcast(self, width, fillchar))
示例#39
0
 def startswith(self, prefix, start=None, end=None):
     return self._typedmethod('startswith',
                              broadcast(self, prefix, start, end), bool)
 def center(self, width):
     return self._generalmethod('center', broadcast(self, width))
示例#41
0
 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))
示例#42
0
 def center(self, width, fillchar=' '):
     return self._generalmethod('center',
                                broadcast(self, width, fillchar))
 def rjust(self, width):
     return self._generalmethod('rjust', broadcast(self, width))
 def count(self, sub, start=None, end=None):
     return self._typedmethod('count', broadcast(self, sub, start, end), int)