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
Beispiel #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
Beispiel #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
Beispiel #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
Beispiel #7
0
 def lstrip(self, chars):
     return self._generalmethod('lstrip', broadcast(self, chars))
Beispiel #8
0
 def find(self, sub, start=None, end=None):
     return self._typedmethod('find', broadcast(self, sub, start, end), int)
Beispiel #9
0
 def endswith(self, suffix, start=None, end=None):
     return self._typedmethod('endswith', broadcast(self, suffix, start,
                                                    end), bool)
Beispiel #10
0
 def count(self, sub, start=None, end=None):
     return self._typedmethod('count', broadcast(self, sub, start, end),
                              int)
Beispiel #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))
Beispiel #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)
Beispiel #20
0
 def rindex(self, sub, start=None, end=None):
     return self._typedmethod('rindex', broadcast(self, sub, start, end),
                              int)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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))
Beispiel #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))
Beispiel #33
0
 def join(self, seq):
     return self._generalmethod('join', broadcast(self, seq))
 def zfill(self, width):
     return self._generalmethod('zfill', broadcast(self, width))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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))
Beispiel #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)