[Please write to the PyTables list from a subscribed address. If not, your messages will not be injected.]
A Tuesday 03 June 2008, escriguéreu: > Thanks! I'll digest that information, which appears to be > complicated. I was looking for a simple call to reset arrays of > certain dimensions (shape is a variable) that are not fixed > dimensions. I may consider recreating the array, and my only concern > is to recreate the attributes of the existing array. Oh, it is not so complicated, really: it's just a matter to be used to the extended slicing notation: http://www.informit.com/articles/article.aspx?p=453682&seqNum=6 [you can go directly to the extended slicing part, but a complete read is recommended] Here it is a simple example for a CArray (but this works for every PyTables Leaf instance): In [4]: test = f.createCArray(f.root, "test", tables.Float32Atom(), (2,10)) In [5]: test[:] Out[5]: array([[ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32) In [17]: test[0, 0:5] = 1 In [18]: test[:] Out[18]: array([[ 1., 1., 1., 1., 1., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]], dtype=float32) In [19]: test[1, 5:10] = 1 In [20]: test[:] Out[20]: array([[ 1., 1., 1., 1., 1., 0., 0., 0., 0., 0.], [ 0., 0., 0., 0., 0., 1., 1., 1., 1., 1.]], dtype=float32) In [23]: test[:, 3:7] = 2 In [24]: test[:] Out[24]: array([[ 1., 1., 1., 2., 2., 2., 2., 0., 0., 0.], [ 0., 0., 0., 2., 2., 2., 2., 1., 1., 1.]], dtype=float32) In [25]: test[:, 1:10:3] = 3 In [26]: test[:] Out[26]: array([[ 1., 3., 1., 2., 3., 2., 2., 3., 0., 0.], [ 0., 3., 0., 2., 3., 2., 2., 3., 1., 1.]], dtype=float32) As you can see, by using the extended slicing notation, it is very easy to overwrite the parts of the array that you are interested in. Hope this helps, -- Francesc Alted Freelance developer Tel +34-964-282-249 ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users