From: Francesc A. <fa...@ca...> - 2006-08-22 21:11:57
|
A Dimarts 22 Agost 2006 08:10, Jan Strube va escriure: > Oh, and yet another question: > In my structure, I have scalar and vectorial quantities. How can I > determine which is which on an unfilled table ? > I am trying row.getTable().col(column_name).ndim, but that seems only to Please, don't use row.getTable() (it is not documented and, in fact, it is= =20 going to disappear in forthcoming PyTables 1.4 series). Instead, bind the=20 table to a name (say, 'table') and use the more effective : table.col(column_name) as this saves quite a few name lookups. > work on filled tables. In my case it simply returns 1 for all columns. > > Is there a way to determine the dimension of the row I am currently > filling ? This is because attribute .ndim of NumPy returns the *number* of dimensions= of=20 the object, and not the shape that it is what you want. Please note that,=20 despite the fact that there is a number of different definitions for=20 the "number of dimensions", in pythonic numerical packages this is always=20 defined as len(shape). The best way of getting the shape for columns without doing an actual read = of=20 the data is accessing directly to the metadata of the Table object: print table.description.baryon2.decayVector.shape or print table.colshapes['baryon2/decayVector'] Check the different attributes of Table in the manual (section 4.6.1)=20 as well as the Description class (section 4.8) for more accessible metadata= =20 info. HTH, =2D-=20 >0,0< Francesc Altet =C2=A0 =C2=A0 http://www.carabos.com/ V V C=C3=A1rabos Coop. V. =C2=A0=C2=A0Enjoy Data "-" |