Exemple #1
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
Exemple #2
0
 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
Exemple #3
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
Exemple #4
0
 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
Exemple #5
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
Exemple #6
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
Exemple #7
0
 def split(self, sep=None, maxsplit=None):
     return self._typedmethod('split', broadcast(self, sep, maxsplit), object)
Exemple #8
0
 def join(self, seq):
     return self._generalmethod('join', broadcast(self, seq))
Exemple #9
0
 def replace(self, old, new, count=None):
     return self._generalmethod('replace', broadcast(self, old, new, count))
Exemple #10
0
 def encode(self,encoding=None,errors=None):
     return self._generalmethod('encode', broadcast(self, encoding, errors))
Exemple #11
0
 def expandtabs(self, tabsize=None):
     return self._generalmethod('endswith', broadcast(self, tabsize))
Exemple #12
0
 def center(self, width):
     return self._generalmethod('center', broadcast(self, width))
Exemple #13
0
 def center(self, width):
     return self._generalmethod('center', broadcast(self, width))
Exemple #14
0
 def replace(self, old, new, count=None):
     return self._generalmethod('replace', broadcast(self, old, new, count))
Exemple #15
0
 def rindex(self, sub, start=None, end=None):
     return self._typedmethod('rindex', broadcast(self, sub, start, end), int)
Exemple #16
0
 def join(self, seq):
     return self._generalmethod('join', broadcast(self, seq))
Exemple #17
0
 def lstrip(self, chars):
     return self._generalmethod('lstrip', broadcast(self, chars))
Exemple #18
0
 def find(self, sub, start=None, end=None):
     return self._typedmethod('find', broadcast(self, sub, start, end), int)
Exemple #19
0
 def expandtabs(self, tabsize=None):
     return self._generalmethod('endswith', broadcast(self, tabsize))
Exemple #20
0
 def endswith(self, suffix, start=None, end=None):
     return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)
Exemple #21
0
 def startswith(self, prefix, start=None, end=None):
     return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)
Exemple #22
0
 def split(self, sep=None, maxsplit=None):
     return self._typedmethod('split', broadcast(self, sep, maxsplit), object)
Exemple #23
0
 def encode(self,encoding=None,errors=None):
     return self._generalmethod('encode', broadcast(self, encoding, errors))
Exemple #24
0
 def splitlines(self, keepends=None):
     return self._typedmethod('splitlines', broadcast(self, keepends), object)
Exemple #25
0
 def rjust(self, width):
     return self._generalmethod('rjust', broadcast(self, width))
Exemple #26
0
 def startswith(self, prefix, start=None, end=None):
     return self._typedmethod('startswith', broadcast(self, prefix, start, end), bool)
Exemple #27
0
 def count(self, sub, start=None, end=None):
     return self._typedmethod('count', broadcast(self, sub, start, end), int)
Exemple #28
0
 def strip(self, chars=None):
     return self._generalmethod('strip', broadcast(self, chars))
Exemple #29
0
 def endswith(self, suffix, start=None, end=None):
     return self._typedmethod('endswith', broadcast(self, suffix, start, end), bool)
Exemple #30
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))
Exemple #31
0
 def find(self, sub, start=None, end=None):
     return self._typedmethod('find', broadcast(self, sub, start, end), int)
Exemple #32
0
 def zfill(self, width):
     return self._generalmethod('zfill', broadcast(self, width))
Exemple #33
0
 def lstrip(self, chars):
     return self._generalmethod('lstrip', broadcast(self, chars))
Exemple #34
0
 def rjust(self, width, fillchar=' '):
     return self._generalmethod('rjust',
                                broadcast(self, width, fillchar))
Exemple #35
0
 def rindex(self, sub, start=None, end=None):
     return self._typedmethod('rindex', broadcast(self, sub, start, end), int)
Exemple #36
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))
Exemple #37
0
 def splitlines(self, keepends=None):
     return self._typedmethod('splitlines', broadcast(self, keepends), object)
Exemple #38
0
 def center(self, width, fillchar=' '):
     return self._generalmethod('center',
                                broadcast(self, width, fillchar))
Exemple #39
0
 def strip(self, chars=None):
     return self._generalmethod('strip', broadcast(self, chars))
Exemple #40
0
 def count(self, sub, start=None, end=None):
     return self._typedmethod('count', broadcast(self, sub, start, end), int)
Exemple #41
0
 def zfill(self, width):
     return self._generalmethod('zfill', broadcast(self, width))
Exemple #42
0
 def center(self, width, fillchar=' '):
     return self._generalmethod('center',
                                broadcast(self, width, fillchar))
Exemple #43
0
 def rjust(self, width, fillchar=' '):
     return self._generalmethod('rjust',
                                broadcast(self, width, fillchar))
Exemple #44
0
 def rjust(self, width):
     return self._generalmethod('rjust', broadcast(self, width))