From: Francesc A. <fa...@py...> - 2009-06-26 16:19:22
|
A Friday 26 June 2009 17:44:48 Didier Roissé escrigué: > Hello, > I created a HDF5 file containing an array with the following dimension > (5000,1). I notice a big difference file size between the array creation > with createCArray and createEArray. > For creation of the table with createCArray, i use this script : > > h5ft=openFile('test_carray.h5','w') > ca=h5ft.createCArray(h5ft.root,"foo",Float32Col(),(5000,1),"carray test") > for ii in range(5000): > ca[ii][0]=1.0 Here is culprit. When assigning to a PyTables object, always specify the indexes in one shot. For example, replace the above line by: ca[ii,0]=1.0 and you are done. Or you can avoid the last index completely too: ca[ii]=1.0 as the input is broadcasted to the affected index. What was happening here is that ca[ii] returns the element ii of the CArray as a (temporary) NumPy array, and when you do ca[ii][0]=1.0, you are modifying that NumPy array, not the value on disk. Hope that helps, -- Francesc Alted |