[Numpy-discussion] Reversing RecArrays

Francesc Altet faltet at carabos.com
Wed Mar 9 10:47:19 CST 2005


Hi,

I would be interested in having a fast way to reverse RecArrays.
Regrettably, the most straightforward way to reverse them does not
work properly:

>>> from numarray import records
>>> r = records.array([('Smith', 1234),\
...                ('Johnson', 1001),\
...                ('Williams', 1357),\
...                ('Miller', 2468)], \
...                names='Last_name, phone_number')
>>> r[::-1]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/lib/python2.3/site-packages/numarray/records.py", line 749, in 
__repr__
    outlist.append(Record.__str__(i))
  File "/usr/lib/python2.3/site-packages/numarray/records.py", line 797, in 
__str__
    outlist.append(`self.array.field(i)[self.row]`)
  File "/usr/lib/python2.3/site-packages/numarray/records.py", line 736, in 
field
    self._fields = self._get_fields()  # Refresh the cache
  File "/usr/lib/python2.3/site-packages/numarray/records.py", line 705, in 
_get_fields
    bytestride=_stride)
  File "/usr/lib/python2.3/site-packages/numarray/strings.py", line 112, in 
__init__
    raise ValueError("Inconsistent string and array parameters.")
ValueError: Inconsistent string and array parameters.

Anyway, anybody knows if there is some way to achieve this (until this
bug would be eventually fixed, of course)?

Thanks,

-- 
>qo<   Francesc Altet     http://www.carabos.com/
V  V   Cárabos Coop. V.   Enjoy Data
 ""





More information about the Numpy-discussion mailing list