[Numpy-discussion] Rename record array fields (with object arrays)
Sameer DCosta
sameerslists@gmail....
Thu Feb 28 14:00:45 CST 2008
I think having a record array field renaming api is a good idea.. I
was going to create a ticket for this, but I don't think I have
permissions to do this. Can someone who has the permissions, please
create it? Thanks.
Sameer
On Thu, Feb 28, 2008 at 10:48 AM, Travis E. Oliphant
<oliphant@enthought.com> wrote:
>
> Sameer DCosta wrote:
> > Hi,
> >
> > I'm having trouble renaming record array fields if they contain object
> > arrays in them. I followed the solutions posted by Robert Kern and
> > Stefan van der Walt (Thanks again) but it doesn't look like this
> > method works in all cases. For reference:
> > http://projects.scipy.org/pipermail/numpy-discussion/2008-February/031509.html
> >
> > In [1]: from numpy import *
> >
> > In [2]: olddt = dtype([('foo', '|O4'), ('bar', float)])
> >
> > In [3]: a = zeros(10, olddt)
> >
> > In [4]: a
> > Out[4]:
> > array([(0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0),
> > (0, 0.0), (0, 0.0), (0, 0.0), (0, 0.0)],
> > dtype=[('foo', '|O4'), ('bar', '<f8')])
> >
> > In [5]: newdt = dtype([('notfoo', '|O4'), ('notbar', float)])
> >
> > In [6]: b = a.view(newdt)
> > ---------------------------------------------------------------------------
> > TypeError Traceback (most recent call last)
> >
> > /home/titan/sameer/projects/<ipython console>
> >
> > TypeError: Cannot change data-type for object array.
> >
>
> This looks like a bug. We are being a bit over-zealous in protecting
> you from getting access to pointers and in the process making it
> impossible to rename Object fields.
>
> Perhaps an actual field-renaming API (which would be relatively easy) is
> useful.
>
> -Travis O.
>
More information about the Numpy-discussion
mailing list