From: Shin <sd...@em...> - 2004-10-08 21:18:46
|
While filling up a table, I met a strange error message. When the appended program is tried with version 0.8.1, only the second trial to use a list of arrays raises an ValueError. But, the manual says I can use a list of numarrays to append multi-rows. What did I miss? Or, a bug? Thanks. >>>>>>>>>>>>>>> test3.py <<<<<<<<<<<<<<<<<< #!/usr/bin/env python from numarray import * from tables import * # By using a list of lists. class Cols(IsDescription): V1 = FloatCol() V2 = FloatCol() f = openFile("test.hd5", "w") tab = f.createTable("/","Data",Cols,"Data") d = [] for i in range(10): d = d + [[1.0,1.0]] tab.append(d) f.close() # By using a list of arrays. f = openFile("test.hd5", "w") tab = f.createTable("/","Data",Cols,"Data") d = [] for i in range(10): d = d + [array([1.0,1.0])] tab.append(d) f.close() >>>>>>>>> Here is the error message caught in ipython <<<<<< In [1]: execfile("test3.py") --------------------------------------------------------------------------- ValueError Traceback (most recent call last) /home/sdhyok/catchlab/catchlab/catchlab/pkg/rhessys/test/<console> /home/sdhyok/catchlab/catchlab/catchlab/pkg/rhessys/test/test3.py 24 for i in range(10): 25 d = d + [array([1.0,1.0])] 26 ---> 27 tab.append(d) tab = /Data (Table(0,)) 'Data' description := { ...pe=1, dflt=0.0, pos=None) } byteorder := little, global append = undefined, d = [array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.])] 28 f.close() /usr/lib/python2.3/site-packages/tables/Table.py in append(self=/Data (Table(0,)) 'Data' description := { ...pe=1, dflt=0.0, pos=None) } byteorder := little, rows=[array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.]), array([ 1., 1.])]) 588 except: 589 (type, value, traceback) = sys.exc_info() --> 590 raise ValueError, \ global ValueError = undefined, global str = undefined, self = /Data (Table(0,)) 'Data' description := { ...pe=1, dflt=0.0, pos=None) } byteorder := little, value = <exceptions.IndexError instance> 591 "rows parameter cannot be converted into a recarray object compliant with table '%s'. The error was: <%s>" % (str(self), value) 592 lenrows = recarray.shape[0] ValueError: rows parameter cannot be converted into a recarray object compliant with table '/Data (Table(0,)) 'Data''. The error was: <list index out of range> -- Daehyok Shin (Peter) Geography Department Univ. of North Carolina-Chapel Hill |