table.read() seems to be broken with:
>>> tables.__version__
'1.3.2'
>>> numpy.__version__
'1.0b4'
Here, I got a test-function that populates a table with different
descriptions and then tries to read()
from tables import openFile,UInt32Col
import itertools
def test(flavor,d):
h1 = openFile('h5_1.h5', mode = "w")
try:
data=itertools.count()
if d=='two':
desc={ 'a': UInt32Col(), 'c':UInt32Col() }
elif d=='three':
desc={ 'a': UInt32Col(), 'c':UInt32Col() , 'd' : UInt32Col() }
elif d=='nested':
desc={ 'a': UInt32Col(), 'b': { 'c' : UInt32Col() } }
elif d=='nested2':
desc={ 'a': UInt32Col(), 'b': { 'c' : UInt32Col(), 'd' :
UInt32Col()} }
t1=h1.createTable('/','test',desc )
t1._g_setflavor(flavor)
r1=t1.row
names=reduce(list.__add__,[type(x)==tuple and ["%s/%s" %
(x[0],y) for y in x[1]] or [x] for x in t1.colnames])
print names
for i in range(4):
for name in names:
r1[name]=data.next()
r1.append()
finally:
h1.flush()
h1.close()
h1 = openFile('h5_1.h5', mode = "r")
try:
t1 = h1.root.test
print "Table length: " , len(t1)
d=t1.read()
print "read() return type :", type(d)
print "read() return shape : ", d.shape
finally:
h1.close()
for numarray everything seems okay:
>>> test('numarray','two')
['a', 'c']
Table length: 4
read() return type : <class 'tables.nestedrecords.NestedRecArray'>
read() return shape : (4,)
>>> test('numarray','three')
['a', 'c', 'd']
Table length: 4
read() return type : <class 'tables.nestedrecords.NestedRecArray'>
read() return shape : (4,)
>>> test('numarray','nested')
['a', 'b/c']
Table length: 4
read() return type : <class 'tables.nestedrecords.NestedRecArray'>
read() return shape : (4,)
>>> test('numarray','nested2')
['a', 'b/c', 'b/d']
Table length: 4
read() return type : <class 'tables.nestedrecords.NestedRecArray'>
read() return shape : (4,)
However, for numpy I got the following error:
>>> test('numpy','two')
['a', 'c']
Table length: 4
read() return type : <class 'numpy.core.records.recarray'>
read() return shape : ()
>>> test('numpy','three')
['a', 'c', 'd']
Table length: 4
Traceback (most recent call last):
File "<pyshell#55>", line 1, in ?
test('numpy','three')
File "C:\ws\Charlotte\PS\test.py", line 33, in test
d=t1.read()
File "C:\Python24\Lib\site-packages\tables\Table.py", line 1195, in read
arr = tonumpy(arr, copy=False)
File "C:\Python24\Lib\site-packages\tables\utils.py", line 716, in tonumpy
npa = numpy.array(buffer, dtype=array.array_descr)
ValueError: Can't get buffer pointer from byteswapped or misaligned array.
>>> test('numpy','nested')
['a', 'b/c']
Table length: 4
read() return type : <class 'numpy.core.records.recarray'>
read() return shape : ()
>>> test('numpy','nested2')
['a', 'b/c', 'b/d']
Table length: 4
Traceback (most recent call last):
File "<pyshell#57>", line 1, in ?
test('numpy','nested2')
File "C:\ws\Charlotte\PS\test.py", line 33, in test
d=t1.read()
File "C:\Python24\Lib\site-packages\tables\Table.py", line 1195, in read
arr = tonumpy(arr, copy=False)
File "C:\Python24\Lib\site-packages\tables\utils.py", line 716, in tonumpy
npa = numpy.array(buffer, dtype=array.array_descr)
ValueError: Can't get buffer pointer from byteswapped or misaligned array.
Is there an quick and easy solution to this problem? For now I guess
I'll have to iterate my tables which takes much more time, especially
when copying one table to another.
Thanks for a great product. I'm looking forward to the numpy migration release!
Best Regards,
//Torgil
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Pytables-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pytables-users