~ubuntu-branches/debian/experimental/h5py/experimental

« back to all changes in this revision

Viewing changes to docs/source/guide/hl.rst

  • Committer: Bazaar Package Importer
  • Author(s): Soeren Sonnenburg
  • Date: 2009-09-24 11:08:03 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20090924110803-hz0en6f43x8opgj4
Tags: 1.2.1-2
Build-depend on hdf5 >= 1.8.3 and enable api 1.8 (Closes: #548049)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
.. _h5pyreference:
 
3
 
 
4
***********************
 
5
Reference Documentation
 
6
***********************
 
7
 
 
8
.. module:: h5py.highlevel
 
9
 
 
10
The high-level interface is the most convenient method to talk to HDF5.  There
 
11
are three main abstractions: files, groups, and datasets. Each is documented
 
12
separately below.
 
13
 
 
14
.. toctree::
 
15
    :maxdepth: 2
 
16
 
 
17
    file
 
18
    group
 
19
    dataset
 
20
    attr
 
21
    vl
 
22
    other
 
23
 
 
24
General information about h5py and HDF5
 
25
=======================================
 
26
 
 
27
Paths in HDF5
 
28
-------------
 
29
 
 
30
HDF5 files are organized like a filesystem.  :class:`Group` objects work like
 
31
directories; they can contain other groups, and :class:`Dataset` objects.  Like
 
32
a POSIX filesystem, objects are specified by ``/``-separated names, with the
 
33
root group ``/`` (represented by the :class:`File` class) at the base.
 
34
 
 
35
Wherever a name or path is called for, it may be relative or absolute.
 
36
Unfortunately, the construct ``..`` (parent group) is not allowed.
 
37
 
 
38
Exceptions
 
39
----------
 
40
 
 
41
As of version 1.2, h5py uses a "hybrid" exception system.  When an error is
 
42
detected inside HDF5, an exception is raised which inherits from both a
 
43
standard Python exception (TypeError, ValueError, etc), and an HDF5-specific
 
44
exception class (a subclass of H5Error).
 
45
 
 
46
It's recommended that you use the standard Python exceptions in you code;
 
47
for example, when indexing a Group object:
 
48
 
 
49
    >>> try:
 
50
    >>>     grp = mygroup[name]
 
51
    >>> except KeyError:
 
52
    >>>     print 'Group "%s" does not exist' % name
 
53
 
 
54
Library configuration
 
55
---------------------
 
56
 
 
57
A few library options are available to change the behavior of the library.
 
58
You can get a reference to the global library configuration object via the
 
59
function ``h5py.get_config()``.  This object supports the following attributes:
 
60
 
 
61
    **complex_names**
 
62
        Set to a 2-tuple of strings (real, imag) to control how complex numbers
 
63
        are saved.  The default is ('r','i').
 
64
 
 
65
    **bool_names**
 
66
        Booleans are saved as HDF5 enums.  Set this to a 2-tuple of strings
 
67
        (false, true) to control the names used in the enum.  The default
 
68
        is ("FALSE", "TRUE").
 
69
 
 
70
Threading
 
71
---------
 
72
 
 
73
H5py is now always thread-safe.  However, as HDF5 does not support thread-level
 
74
concurrency (and as it is not necessarily thread-safe), access to the library
 
75
is automatically serialized.  The GIL is released around read/write operations
 
76
so that non-HDF5 threads (GUIs, computation) can continue to execute.
 
77
 
 
78
 
 
79