[Numpy-discussion] numarray.concatenate for character arrays

Faheem Mitha faheem at email.unc.edu
Mon Jun 21 17:18:02 EDT 2004


Dear People,

Is the function numarray.concatenate supposed to work for character
arrays? It doesn't for me. Do I need to write my own? Thanks in
advance. Please cc me, I'm not subscribed.

                                                           Faheem.

In [17]: foo
Out[17]:
CharArray([['T', 'T'],
           ['C', 'A']])

In [18]: bar
Out[18]:
CharArray([['G', 'G'],
           ['G', 'G']])

In [23]: numarray.concatenate((foo,bar))
---------------------------------------------------------------------------
error                                     Traceback (most recent call
last)

/home/faheem/wc/corrmodel/trunk/<console>

/usr/lib/python2.3/site-packages/numarray/generic.py in
concatenate(arrs, axis)
   1018     arrs = map(_nc.asarray, arrs)
   1019     if axis == 0:
-> 1020         return _concat(arrs)
   1021     else:
   1022         return swapaxes(_concat([swapaxes(m,axis,0) for m in
   arrs]), axis, 0)

/usr/lib/python2.3/site-packages/numarray/generic.py in _concat(arrs)
   1000         convType = ufunc._maxPopType(arrs)
   1001     except TypeError:
-> 1002         dest = arrs[0]._clone(shape=destShape)
   1003     else:
   1004         dest  = arrs[0].__class__(shape=destShape,
   type=convType)

/usr/lib/python2.3/site-packages/numarray/generic.py in _clone(self,
shape)
    783     def _clone(self, shape):
    784         c = self.copy()
--> 785         c.resize(shape)
    786         return c
    787

/usr/lib/python2.3/site-packages/numarray/generic.py in resize(self,
shape, *args)
    854                     self[offset:offset+olen] = self[0:olen]
    855                     offset += olen
--> 856                 self[offset:nlen] = self[0:nlen-offset]
    857         else:   # zero fill resized zero-length numarray
    858             self[:] = 0

/usr/lib/python2.3/site-packages/numarray/strings.py in
_copyFrom(self, arr)
    217         me = self._byteView()
    218         if self._itemsize <= arr._itemsize:
--> 219             me[:] = it[..., :self._itemsize]
    220         else:
    221             me[...,:it._shape[-1]] = it

error: copy1bytes: access beyond buffer. offset=8 buffersize=8







More information about the NumPy-Discussion mailing list