Hello Martin, First of all: nice job!
Now, apart of some small technical details, the thing that I find the most 'arguable' is the fact that you have introduced a new dtype (typecode 'r') for NumPy (good trick, BTW). Is that strictly necessary? My worries is that NumPy would decide in the future to make use of the 'r' typecode, in which case, we would have a problem. Would not it be possible to use plain python nested lists for this? I find the latter preferable, but perhaps you have some use case for wanting a native NumPy typecode. Also, I don't see that you have made a proper implementation of 'Dimension Scales' as understood in: http://ftp.hdfgroup.org/HDF5/Tutor/h5dimscale.html but only support for HDF5 references (but I suppose that, with a little more of work we can be there...) Finally, I miss some test units, but that should easy to solve. If you agree to work with that, I'd like to open a new public branch in the PyTables repository and give you commit permissions there. We can continue discussing the issues here so that other people can contribute with opinions, test units, docstrings or whatever. Thanks! Francesc A Saturday 17 October 2009 18:18:56 Martin Teichmann escrigué: > Hello List, > > (Sorry, due to a typo the email I just sent was > incomplete. Here the full version). > > a while ago, I proposed an extension to pytables > which would allow for HDF5 dimension scales to > be read. Not on a high level, though, just > giving access to the kind of attributes that is used > in their implementation, especially references > and variable-length list attributes. > > After some more suggestions from this list, I figured > out that a completely different approach is better, > and so I reimplemented the same as follows: > > I introduced a new numpy data type, conveniently > called reference, which corresponds to a HDF5 > reference. Now one can make arrays of references, > even record arrays of references, and also store them > (via pytables) into a HDF5 file. > > Secondly, I modified setAttr so that if it is given > a list of numpy arrays of all same datatype, a variable > length array is created as an attribute. > > To illustrate that, I give a little example: > > -------------- snip ---------------- > from __future__ import with_statement > import tables > from tables import reference > from numpy import array, arange > > with tables.openFile("test.h5", mode="w", title="test") as file: > group = file.createGroup("/", "G", "group") > > dataA = file.createArray(group, "A", array([1,2,3]), "data") > dataB = file.createArray(group, "B", array([4,5,6]), "data") > dataC = file.createArray(group, "C", array([7,8,9]), "data") > file.flush() > > # this is how we create a reference: > ref = tables.reference(dataA) > print array([ref]) > dataB.attrs.dataA = array([ref]) > # weird record arrays of reference and integer types are possible: > a = array([(2, ref), (3, ref)], dtype=[("l", "i"), ("s", "r")]) > print a.dtype > print a.dtype.base > dataB.attrs.dataL = a > # a list of arrays gets transformed into a vlen list: > dataB.attrs.list = [ arange(7), arange(9) ] > # but certainly this was intended for list of references > dataB.attrs.reflist = [ array([ref]), > array([ref, tables.reference(dataB)]) ] > print dataB.attrs.reflist > > dataB.attrs.dataR = ref > print ref > print ref.deref(file) > l = ref > ref = tables.reference(dataB) > > print "-----------" > > with tables.openFile("test.h5", mode="r") as file: > r = file.root > > ref = r.G.B.attrs.dataA > print ref > print ref[0].deref(file) > print r.G.B.attrs.dataL > print r.G.B.attrs.list > print r.G.B.attrs.reflist > --------------- snip --------- > > The code will follow in more emails to come. > > Greetings > > Martin > > --------------------------------------------------------------------------- >--- Come build with us! The BlackBerry(R) Developer Conference in SF, CA is > the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9 - 12, 2009. Register now! > http://p.sf.net/sfu/devconference > _______________________________________________ > Pytables-users mailing list > Pytables-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/pytables-users -- Francesc Alted ------------------------------------------------------------------------------ Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now! http://p.sf.net/sfu/devconference _______________________________________________ Pytables-users mailing list Pytables-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/pytables-users