f1['big'] notation in "Python and HDF5" book

32 views
Skip to first unread message

Alan Robinson

unread,
Aug 3, 2020, 11:54:37 AM8/3/20
to h5py
in the middle of p. 24 of the standard reference work "Python and HDF5" by Andrew Collette he suddenly switches to a new notation using square brackets:

>>> with h5py.File('big1.hdf5', 'w') as f1:
...           f1['big'] = bigdata

I assume that this new notation is somewhere defined in the NumPy literature, but where? 

Also the biotechnology company 10X Genomics has made available on the web sample code for processing the HDF5 files produced by its software supporting their single cell RNA-seq hardware platform, which uses a more elaborate notation, e.g.:

     f['matrix'] ['features']['id']

Unfortunately due to rapid technological advances they regard this sample code as technically obsolete and therefore unsupported, even though it applies to experimental data on Covid-19 infections which has been publicly deposited in just the last couple of months. Please note that my immediate problem is just trying to understand the programming notation, not the 10X Genomics technology.

Any help would be greatly appreciated!
   

Thomas Kluyver

unread,
Aug 3, 2020, 12:00:27 PM8/3/20
to h5...@googlegroups.com
Hi Alan,

You can think of an HDF5 file as a dictionary containing arrays. This f['name'] syntax just gets or stores one array (a 'dataset', to use the HDF5 term), which you can then slice like a numpy array.

HDF5 calls this dictionary-like interface a 'group', and one group can contain subgroups, which is what's happening in your f['matrix']['features']['id'] example. It could also be written f['matrix/features/id'] .

Thomas

--
You received this message because you are subscribed to the Google Groups "h5py" group.
To unsubscribe from this group and stop receiving emails from it, send an email to h5py+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/h5py/af7dee14-195c-42d8-8343-0062ab151bfeo%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages