diff options
author | Travis Oliphant <oliphant@enthought.com> | 2005-12-13 06:54:34 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2005-12-13 06:54:34 +0000 |
commit | a20e397e881f3b6c60d00a2195f79b87642f0cb7 (patch) | |
tree | e278f2bd60cd951df7537ac2ee3871504b7a2319 /scipy/base/chararray.py | |
parent | f0995b54db038fa8e1ecfecf51c2519e48e10043 (diff) | |
download | numpy-a20e397e881f3b6c60d00a2195f79b87642f0cb7.tar.gz |
Fixed so swapped record arrays get converted properly.
Diffstat (limited to 'scipy/base/chararray.py')
-rw-r--r-- | scipy/base/chararray.py | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/scipy/base/chararray.py b/scipy/base/chararray.py index 3133de07b..0bcc07b54 100644 --- a/scipy/base/chararray.py +++ b/scipy/base/chararray.py @@ -63,7 +63,7 @@ class chararray(ndarray): b = broadcast(self, other) arr = b.iters[1].base outitem = self.itemsize + arr.itemsize - result = ndchararray(b.shape, outitem, self.dtype is unicode_) + result = chararray(b.shape, outitem, self.dtype is unicode_) res = result.flat for k, val in enumerate(b): res[k] = (val[0] + val[1]) @@ -73,7 +73,7 @@ class chararray(ndarray): b = broadcast(other, self) outitem = b.iters[0].base.itemsize + \ b.iters[1].base.itemsize - result = ndchararray(b.shape, outitem, self.dtype is unicode_) + result = chararray(b.shape, outitem, self.dtype is unicode_) res = result.flat for k, val in enumerate(b): res[k] = (val[0] + val[1]) @@ -85,7 +85,7 @@ class chararray(ndarray): if not issubclass(arr.dtype, integer): raise ValueError, "Can only multiply by integers" outitem = b.iters[0].base.itemsize * arr.max() - result = ndchararray(b.shape, outitem, self.dtype is unicode_) + result = chararray(b.shape, outitem, self.dtype is unicode_) res = result.flat for k, val in enumerate(b): res[k] = val[0]*val[1] @@ -97,7 +97,7 @@ class chararray(ndarray): if not issubclass(arr.dtype, integer): raise ValueError, "Can only multiply by integers" outitem = b.iters[0].base.itemsize * arr.max() - result = ndchararray(b.shape, outitem, self.dtype is unicode_) + result = chararray(b.shape, outitem, self.dtype is unicode_) res = result.flat for k, val in enumerate(b): res[k] = val[0]*val[1] @@ -111,7 +111,7 @@ class chararray(ndarray): newval = val[0] % val[1] maxsize = max(len(newval), maxsize) res[k] = newval - newarr = ndchararray(b.shape, maxsize, self.dtype is unicode_) + newarr = chararray(b.shape, maxsize, self.dtype is unicode_) nearr[:] = res return newarr @@ -130,7 +130,7 @@ class chararray(ndarray): newitem = getattr(val[0],name)(*newval) maxsize = max(len(newitem), maxsize) res[k] = newitem - newarr = ndchararray(myiter.shape, maxsize, self.dtype is unicode_) + newarr = chararray(myiter.shape, maxsize, self.dtype is unicode_) print res, maxsize newarr[:] = res return newarr @@ -284,7 +284,7 @@ class chararray(ndarray): def array(obj, itemlen=7, copy=True, unicode=False, fortran=False): - if isinstance(obj, ndchararray): + if isinstance(obj, chararray): if copy or (itemlen != obj.itemlen) \ or (not unicode and obj.dtype == unicode_) \ or (unicode and obj.dtype == string): @@ -308,7 +308,7 @@ def array(obj, itemlen=7, copy=True, unicode=False, fortran=False): if copy and not copied: obj = obj.copy() - return ndarray.__new__(ndchararray, obj.shape, (dtype, itemlen), + return ndarray.__new__(chararray, obj.shape, (dtype, itemlen), buffer=obj, offset=0, swap=obj.flags.swapped, fortran=obj.flags['FNC']) |