[Numpy-discussion] fromrecords yields "ValueError: invalid itemsize in generic type tuple"
Rajat Banerjee
rbanerj at fas.harvard.edu
Mon Dec 6 22:20:35 EST 2010
Hi All,
I have been using Numpy for a while with great success. I left my
little project for a little while
(http://web.mit.edu/stardev/cluster/) and now some of my code is
broken.
I have some Numpy code to create graphs of activity on a cluster with
matplotlib. It ran just fine in July / August 2010, but has since
stopped working. I have updated numpy on my machine, I think.
In [2]: np.version.version
Out[2]: '1.5.1'
My call to np.rec.fromrecords() is throwing this exception:
File "/home/rajat/Envs/StarCluster/lib/python2.6/site-packages/numpy/core/records.py",
line 607, in fromrecords
descr = sb.dtype((record, dtype))
ValueError: invalid itemsize in generic type tuple
Here is the code with some irrelevant stuff stripped:
for line in file:
a = [datetime.strptime(parts[0], '%Y-%m-%d %H:%M:%S.%f'),
int(parts[1]), int(parts[2]), int(parts[3]), int(parts[4]),
int(parts[5]), int(parts[6]), float(parts[7])]
list.append(a)
file.close()
names = ['dt', 'hosts', 'running_jobs', 'queued_jobs',\
'slots', 'avg_duration', 'avg_wait', 'avg_load']
descriptor = {'names':
('dt,hosts,running_jobs,queued_jobs,slots,avg_duration,avg_wait,avg_load'),\
'formats' : ('S20','u','u','u','u','u','u','f')}
self.records = np.rec.fromrecords(list,','.join(names)) #used to work
#self.records = np.rec.fromrecords(list, dtype=descriptor) #new attempt
Here is one "line" from the array "list":
>>> parts (8) = ['2010-12-07 03:09:46.855712', '2', '2', '177', '2', '86', '370', '1.05'].
Neither of those np.rec.fromrecords() calls works. I've tried both
separately. They both throw the exact same exception, ValueError:
invalid itemsize in generic type tuple
Can anybody help me? Am I doing something dumb?
Thank you.
Rajat Banerjee
Masters Candidate, Computer Science, Harvard University
More information about the NumPy-Discussion
mailing list