Hello All,
As per the createTable()
documentation<http://www.pytables.org/docs/manual/ch04.html#TableClassDescr>,
I tried to make a new table using a numpy dtype as the description.
However, doing so fails with the following traceback:
Traceback (most recent call last):
File "table_dtype.py", line 38, in <module>
table = f.createTable(f.root, 'table', dt, expectedrows=10)
File "/usr/lib64/python2.6/site-packages/tables/file.py", line 718, in
createTable
chunkshape=chunkshape, byteorder=byteorder)
File "/usr/lib64/python2.6/site-packages/tables/table.py", line 558, in
__init__
"the ``description`` argument is not of a supported type: "
TypeError: the ``description`` argument is not of a supported type:
``IsDescription`` subclass, ``Description`` instance, dictionary, or record
array
Putting in the array itself works, however. Below is a sample code that
demonstrates this using the Particle example from the tutorial.
Should I open a ticket for this? How difficult would this be to fix? Is it
just a type checking error? Obviously the code to turn a dtype into a
Description exists somewhere, because it is being used when an array is
supplied. Thanks for your support!
Be Well
Anthony
--------
import tables
import numpy as np
# Make data type
dt = np.dtype([
('name', 'S16'), # 16-character String
('idnumber', np.int64), # Signed 64-bit integer
('ADCcount', np.uint16), # Unsigned short integer
('TDCcount', np.uint8), # unsigned byte
('grid_i', np.int32), # 32-bit integer
('grid_j', np.int32), # 32-bit integer
('pressure', np.float32), # float (single-precision)
('energy', np.float64), # double (double-precision)
])
# Fill data structure
data = []
for i in xrange(10):
particle = {}
particle['name'] = 'Particle: %6d' % (i)
particle['TDCcount'] = i % 256
particle['ADCcount'] = (i * 256) % (1 << 16)
particle['grid_i'] = i
particle['grid_j'] = 10 - i
particle['pressure'] = float(i*i)
particle['energy'] = float(particle['pressure'] ** 4)
particle['idnumber'] = i * (2 ** 34)
# Insert a new particle record
data.append( (particle['name'], particle['idnumber'],
particle['ADCcount'],
particle['TDCcount'], particle['grid_i'],
particle['grid_j'],
particle['pressure'], particle['energy']) )
data = np.array(data, dtype=dt)
# Make table
f = tables.openFile('data.h5', 'w')
# The following is broken
table = f.createTable(f.root, 'table', dt, expectedrows=10)
table.append(data)
# The following works
#table = f.createTable(f.root, 'table', data, expectedrows=10)
f.close()
------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3.
Spend less time writing and rewriting code and more time creating great
experiences on the web. Be a part of the beta today
http://p.sf.net/sfu/msIE9-sfdev2dev
_______________________________________________
Pytables-users mailing list
Pytables-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pytables-users