David Worrall (el 2007-12-03 a les 00:28:15 +1100) va dir:: > Excellent - thank you both - > I had forgotten the python 'row[:] ' technique since I migrated a few > years ago to using tuple() and list(). > > And the second way is probably faster for computation, no? , - they're > going in and out of a couple of dicts
Well, the implementation of both is little more than one ``.item()``
call away. :) However, I'd be carefull when using NumPy records as dict
keys, since they are hashable but also mutable::
In [37]:a = numpy.rec.array([(1,'a'), (2,'b')])
In [38]:r = a[0]
In [39]:rr = r.copy()
In [40]:d = {r: 'x'}
In [41]:d
Out[41]:{(1, 'a'): 'x'}
In [42]:d[r]
Out[42]:'x'
In [43]:d[rr]
---------------------------------------------------------------------------
<type 'exceptions.KeyError'> Traceback (most recent call last)
/home/ivan/<ipython console> in <module>()
<type 'exceptions.KeyError'>: (1, 'a')
In [44]:r['f1'] = 'z'
In [45]:d
Out[45]:{(1, 'z'): 'x'}
> Beautiful tool BTW, thanks!
Glad to hear that! :)
::
Ivan Vilata i Balaguer >qo< http://www.carabos.com/
Cárabos Coop. V. V V Enjoy Data
""
signature.asc
Description: Digital signature
------------------------------------------------------------------------- SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
_______________________________________________ Pytables-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/pytables-users
