|
From: Francesc A. <fa...@ca...> - 2006-02-06 18:52:43
|
Hi,
I've implemented a simple mapping protocol in the descriptor type so
that the user would be able to do:
In [138]:dtype =3D numpy.dtype([
.....: ('x', '<i4', (2,)),
.....: ('Info',[
.....: ('name', '<U120'),
.....: ('weight', '<f4')])])
In [139]:dtype['Info'].name
Out[139]:'void3872'
In [140]:dtype['Info']['name'].type
Out[140]:<type 'unicodescalar'>
instead of the current:
In [141]:dtype.fields['Info'][0].name
Out[141]:'void3872'
In [142]:dtype.fields['Info'][0].fields['name'][0].type
Out[142]:<type 'unicodescalar'>
which I find cumbersome to type. Find the patch for this in the
attachments.
OTOH, I've completed the tests for heterogeneous objects in
test_numerictypes.py. Now, there is a better check for both flat and
nested fields, as well as explicit checking of type descriptors
(including tests for the new mapping interface in descriptors). So far,
no more problems have been detected by the new tests :-). Please, note
that you will need the patch above applied in order to run the tests.
Travis, if you think that it would be better to do not apply the patch,
the tests can be easily adapted by changing lines like:
self.assert_(h.dtype['x'][0].name[:4] =3D=3D 'void')=20
by
self.assert_(h.dtype.fields['x'][0].name[:4] =3D=3D 'void')=20
Cheers,
--=20
>0,0< Francesc Altet http://www.carabos.com/
V V C=E1rabos Coop. V. Enjoy Data
"-"
|