[Numpy-discussion] recarray behaviour

Jonathan Taylor jonathan.taylor at stanford.edu
Thu May 4 10:48:05 EDT 2006


I posted a message to this list about a weird recarray error (and sent a 
second one with the actual pickled data that failed for me).

Just wondering if anyone is/was able to reproduce this error. In 
recarray.py and recarrayII.py I have the exact same dtype description 
and try to create an array with the exact same list (their equality 
evaluates to True, and printed they are identical), but one raises an 
error, the other doesn't. Further, I can't use pdb to investigate the 
error...

I have another example (recarrayIII.py) that gives this same error and 
behaves rather unpythonically (if that really is a word....).

I couldn't figure out what was going on based on the recarray 
description in the numpy book.

=========================================

jtaylo at kff:~/Desktop$ python recarrayII.py
[(12.0, (2005, 4, 22, 0, 0, 0, 4, 112, -1), 501.0, 1.0, 2.0, 0.0, 0.0, 
1.0, 91.5, 1.0, 1.0, 87.0, 1.0, 129.0, 76.0, 107.0, 11.0), (24.0, (2005, 
2, 1, 0, 0, 0, 1, 32, -1), 504.0, 1.0, 2.0, 0.0, 0.0, 1.0, 166.0, 2.0, 
1.0, 84.0, 1.0, 128.0, 78.0, 401.0, 7.0)]
[('Week', '<f4'), ('Date', [('tm_year', '<i2'), ('tm_mon', '<i2'), 
('tm_mday', '<i2'), ('tm_hour', '<i2'), ('tm_min', '<i2'), ('tm_sec', 
'<i2'), ('tm_wday', '<i2'), ('tm_yday', '<i2'), ('tm_isdst', '<i2')]), 
('Institution', '<f4'), ('SeqNo', '<f4'), ('HeightDone', '<f4'), 
('Height', '<f4'), ('UnitsH', '<f4'), ('WeightDone', '<f4'), ('Weight', 
'<f4'), ('Units', '<f4'), ('PulseDone', '<f4'), ('Pulse', '<f4'), 
('BPdone', '<f4'), ('BPSys', '<f4'), ('BPDia', '<f4'), ('PID', '<f4'), 
('RN', '<f4')]
Traceback (most recent call last):
  File "recarrayII.py", line 8, in ?
    a = N.array(v[0:2], dtype=desc)
TypeError: expected a readable buffer object

=========================================
jtaylo at kff:~/Desktop$ python recarray.py
[(12.0, (2005, 4, 22, 0, 0, 0, 4, 112, -1), 501.0, 1.0, 2.0, 0.0, 0.0, 
1.0, 91.5, 1.0, 1.0, 87.0, 1.0, 129.0, 76.0, 107.0, 11.0), (24.0, (2005, 
2, 1, 0, 0, 0, 1, 32, -1), 504.0, 1.0, 2.0, 0.0, 0.0, 1.0, 166.0, 2.0, 
1.0, 84.0, 1.0, 128.0, 78.0, 401.0, 7.0)]
[('Week', '<f4'), ('Date', [('tm_year', '<i2'), ('tm_mon', '<i2'), 
('tm_mday', '<i2'), ('tm_hour', '<i2'), ('tm_min', '<i2'), ('tm_sec', 
'<i2'), ('tm_wday', '<i2'), ('tm_yday', '<i2'), ('tm_isdst', '<i2')]), 
('Institution', '<f4'), ('SeqNo', '<f4'), ('HeightDone', '<f4'), 
('Height', '<f4'), ('UnitsH', '<f4'), ('WeightDone', '<f4'), ('Weight', 
'<f4'), ('Units', '<f4'), ('PulseDone', '<f4'), ('Pulse', '<f4'), 
('BPdone', '<f4'), ('BPSys', '<f4'), ('BPDia', '<f4'), ('PID', '<f4'), 
('RN', '<f4')]
jtaylo at kff:~/Desktop$
========================================

jtaylo at kff:~/Desktop$ python recarrayIII.py
[(3.0,) (4.0,)]
Traceback (most recent call last):
  File "recarrayIII.py", line 6, in ?
    print N.array([[3],[4]], dtype=desc)
TypeError: expected a readable buffer object
jtaylo at kff:~/Desktop$
==========================================

Any help would be greatly appreciated,

Thanks,

Jonathan

-- 
------------------------------------------------------------------------
I'm part of the Team in Training: please support our efforts for the
Leukemia and Lymphoma Society!

http://www.active.com/donate/tntsvmb/tntsvmbJTaylor

GO TEAM !!!

------------------------------------------------------------------------
Jonathan Taylor                           Tel:   650.723.9230
Dept. of Statistics                       Fax:   650.725.8977
Sequoia Hall, 137                         www-stat.stanford.edu/~jtaylo
390 Serra Mall
Stanford, CA 94305

-------------- next part --------------
A non-text attachment was scrubbed...
Name: recarray.py
Type: text/x-python
Size: 1518 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060504/f41cac30/attachment.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recarrayII.py
Type: text/x-python
Size: 135 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060504/f41cac30/attachment-0001.py>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: dump.pickle
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060504/f41cac30/attachment.ksh>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: recarrayIII.py
Type: text/x-python
Size: 148 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060504/f41cac30/attachment-0002.py>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jonathan.taylor.vcf
Type: text/x-vcard
Size: 329 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20060504/f41cac30/attachment.vcf>


More information about the NumPy-Discussion mailing list