[Numpy-discussion] dtype names and titles

Francesc Altet faltet at carabos.com
Mon Feb 13 06:08:15 EST 2006


El dl 13 de 02 del 2006 a les 08:35 -0500, en/na Alan G Isaac va
escriure:
> >> Is anybody actually using both names and titles? 
> 
> On Mon, 13 Feb 2006, Francesc Altet apparently wrote: 
> > Not me. 
> 
> Is the "title" the appropriate storage for the "displayname"
> for fields that are to be plotted?  Or not?

Uh, yes. Perhaps I messed up things. Of course it is interesting to have
both a name and a title. What I tried to mean is that accessing fields
by *both* names and titles might introduce confusion. For example,
allowing:

>>> mydata = [(1,1), (2,4), (3,9)]

>>> mytype = {'names': ['col1','col2'], 'formats':['i2','f4'],'titles':
['col 2', 'col 1']}
>>> b = numpy.array( mydata, dtype=mytype)
>>> b
array([(1, 1.0), (2, 4.0), (3, 9.0)], dtype=(void,6))
>>> b['col1']
array([1, 2, 3], dtype=int16)
>>> b['col 2']
array([1, 2, 3], dtype=int16)

seems quite strange to me. My point is that I think that keys in arrays
for accessing fields should be unique, and thus, I'd remove the last
sentence as a valid one.

But of course I think that having both names and titles is a good thing.
Sorry for the confusion.

Cheers,

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






More information about the NumPy-Discussion mailing list