[h5py] 308/455: Cleanup & minor fixes

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:45 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.

commit df9dca128e38cba0873a7c9ca3f417e6f3b06203
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Thu Sep 10 04:56:45 2009 +0000

    Cleanup & minor fixes
---
 h5py/h5.pyx        | 52 ++++++++++++++++++++++++++++++++++++++--------------
 h5py/h5a.pyx       |  1 -
 h5py/h5d.pyx       | 13 ++-----------
 h5py/h5e.pxd       | 11 +++++++++++
 h5py/h5e.pyx       | 11 +++++++++++
 h5py/h5f.pyx       |  2 +-
 h5py/h5fd.pyx      |  4 ++++
 h5py/h5g.pyx       | 20 ++++++++++----------
 h5py/h5i.pyx       |  2 +-
 h5py/h5l.pyx       |  2 --
 h5py/h5l_body.pyx  |  5 +++--
 h5py/h5o.pyx       |  1 -
 h5py/h5o_body.pyx  | 15 +++++++++++----
 h5py/h5p.pyx       |  2 +-
 h5py/h5r.pyx       |  2 +-
 h5py/h5s.pyx       |  2 +-
 h5py/h5t.pyx       | 49 +++++++++++++++++++++++++++++++------------------
 h5py/h5z.pyx       |  3 +--
 h5py/selections.py | 12 ++++++++++++
 19 files changed, 139 insertions(+), 70 deletions(-)

diff --git a/h5py/h5.pyx b/h5py/h5.pyx
index 10c5065..7de639b 100644
--- a/h5py/h5.pyx
+++ b/h5py/h5.pyx
@@ -9,15 +9,14 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     Common support and versioning module for the h5py HDF5 interface.
 
     This is an internal module which is designed to set up the library and
-    enables HDF5 exception handling.  It also enables debug logging, if the
-    library has been compiled with a nonzero debugging level.
+    enables HDF5 exception handling.
 
-    All exception classes and error handling functions are also in this module.
+    Exception classes are now located in the module h5py.h5e.
 """
 
 include "config.pxi"
@@ -76,12 +75,30 @@ cdef class SmartStruct:
 cdef class H5PYConfig:
 
     """
-        Provides runtime access to global library settings.
+        Provides runtime access to global library settings.  You retrieve the
+        master copy of this object by calling h5py.get_config().
+
+        API_16 (T/F, readonly)
+            Is the HDF5 1.6 API available?  Currently always true.
+
+        API_18 (T/F, readonly)
+            If the HDF5 1.8 API available?
+        
+        DEBUG (integer, readonly)
+            Gives the debug logging level, or 0 if built without logging.
+
+        complex_names (tuple, r/w)
+            Settable 2-tuple controlling how complex numbers are saved.
+            Defaults to ('r','i').
+
+        bool_names (tuple, r/w)
+            Settable 2-tuple controlling the HDF5 enum names used for boolean
+            values.  Defaults to ('FALSE', 'TRUE') for values 0 and 1.
     """
 
     def __init__(self):
-        self.API_16 = H5PY_16API
-        self.API_18 = H5PY_18API
+        self.API_16 = bool(H5PY_16API)
+        self.API_18 = bool(H5PY_18API)
         self.DEBUG = H5PY_DEBUG
         self._r_name = 'r'
         self._i_name = 'i'
@@ -144,7 +161,7 @@ cdef H5PYConfig cfg = H5PYConfig()
 cpdef H5PYConfig get_config():
     """() => H5PYConfig
 
-    Get a reference to the global library configuration object
+    Get a reference to the global library configuration object.
     """
     return cfg
 
@@ -177,14 +194,13 @@ def loglevel(lev):
 cdef class PHIL:
 
     """
+        Warning:  This is an internal h5py object.  Don't use it in your code.
+
         The Primary HDF5 Interface Lock (PHIL) is a global reentrant lock
         which manages access to the library.  HDF5 is not guaranteed to 
         be thread-safe, and certain callbacks in h5py can execute arbitrary
         threaded Python code, defeating the normal GIL-based protection for
         extension modules.  Therefore, in all routines acquire this lock first.
-
-        You should NOT use this object in your code.  It's internal to the
-        library.
     """
 
     def __init__(self):
@@ -208,12 +224,12 @@ cdef PHIL phil = PHIL()
 cpdef PHIL get_phil():
     """() => PHIL
 
-    Obtain a reference to the PHIL.
+    Obtain a reference to the PHIL.  For debugging and internal use only.
     """
     global phil
     return phil
 
-# Everything required for the decorator is now defined
+# Everything required for these decorators is now defined
 
 from _sync import sync, nosync
 
@@ -365,12 +381,16 @@ def get_libversion():
 @sync
 def _close():
     """ Internal function; do not call unless you want to lose all your data.
+
+    Proxy for H5close().
     """
     H5close()
 
 @sync
 def _open():
     """ Internal function; do not call unless you want to lose all your data.
+
+    Proxy for H5open().
     """
     H5open()
 
@@ -405,9 +425,12 @@ def _exithack():
 
 hdf5_inited = 0
 
+# Proxy function which returns the predefined HDF5 type corresponding to
+# a Python object pointer (opaque type with size sizeof(void*)).
 cdef hid_t get_object_type() except -1:
     return h5py_object_type()
 
+# Proxy functions for r/w with workarounds for various HDF5 bugs.
 cdef herr_t dset_rw(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, 
                     hid_t file_space_id, hid_t xfer_plist_id, void *outbuf,
                     h5py_rw_t dir) except *:
@@ -446,7 +469,8 @@ _api_version_tuple = (int(H5PY_API/10), H5PY_API%10)
 _version_tuple = tuple([int(x) for x in H5PY_VERSION.split('-')[0].split('.')])
 _version_string = H5PY_VERSION
 
-
+# For backwards compatibility with user code used to the exception classes
+# being in this module.
 from h5e import H5Error
 
 
diff --git a/h5py/h5a.pyx b/h5py/h5a.pyx
index b3a2221..e23a630 100644
--- a/h5py/h5a.pyx
+++ b/h5py/h5a.pyx
@@ -10,7 +10,6 @@
 # 
 #-
 
-__doc__=\
 """
     Provides access to the low-level HDF5 "H5A" attribute interface.
 """
diff --git a/h5py/h5d.pyx b/h5py/h5d.pyx
index f7d598e..767d86d 100644
--- a/h5py/h5d.pyx
+++ b/h5py/h5d.pyx
@@ -9,10 +9,11 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     Provides access to the low-level HDF5 "H5D" dataset interface.
 """
+
 include "config.pxi"
 
 # Compile-time imports
@@ -154,11 +155,6 @@ cdef class DatasetID(ObjectID):
             wide variety of dataspace configurations are possible, this is not
             checked.  You can easily crash Python by reading in data from too
             large a dataspace.
-
-            The actual read is non-blocking; the array object is temporarily
-            marked read-only, but attempting to mutate it in another thread
-            is a bad idea.  All HDF5 API calls are locked until the read
-            completes.
         """
         cdef hid_t self_id, mtype_id, mspace_id, fspace_id, plist_id
         cdef void* data
@@ -193,11 +189,6 @@ cdef class DatasetID(ObjectID):
 
             The provided Numpy array must be C-contiguous.  If this is not the
             case, ValueError will be raised and the read will fail.
-
-            The actual write is non-blocking; the array object is temporarily
-            marked read-only, but attempting to mutate it in another thread
-            is a bad idea.  All HDF5 API calls are locked until the write
-            completes.
         """
         cdef hid_t self_id, mtype_id, mspace_id, fspace_id, plist_id
         cdef void* data
diff --git a/h5py/h5e.pxd b/h5py/h5e.pxd
index fa3d1df..58ed868 100644
--- a/h5py/h5e.pxd
+++ b/h5py/h5e.pxd
@@ -1,3 +1,14 @@
+#+
+# 
+# This file is part of h5py, a low-level Python interface to the HDF5 library.
+# 
+# Copyright (C) 2008 Andrew Collette
+# http://h5py.alfven.org
+# License: BSD  (See LICENSE.txt for full license)
+# 
+# $Date$
+# 
+#-
 
 """
     Definitions file for new H5E module
diff --git a/h5py/h5e.pyx b/h5py/h5e.pyx
index 4f4d594..07ee60b 100644
--- a/h5py/h5e.pyx
+++ b/h5py/h5e.pyx
@@ -1,3 +1,14 @@
+#+
+# 
+# This file is part of h5py, a low-level Python interface to the HDF5 library.
+# 
+# Copyright (C) 2008 Andrew Collette
+# http://h5py.alfven.org
+# License: BSD  (See LICENSE.txt for full license)
+# 
+# $Date$
+# 
+#-
 
 """
     Implements HDF5 error support and Python exception translation.
diff --git a/h5py/h5f.pyx b/h5py/h5f.pyx
index 931ba72..f3fd8cd 100644
--- a/h5py/h5f.pyx
+++ b/h5py/h5f.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     Low-level operations on HDF5 file objects.
 """
diff --git a/h5py/h5fd.pyx b/h5py/h5fd.pyx
index 3c6e7f6..f6a8540 100644
--- a/h5py/h5fd.pyx
+++ b/h5py/h5fd.pyx
@@ -13,6 +13,10 @@
 # This file contains code or comments from the HDF5 library.  See the file
 # licenses/hdf5.txt for the full HDF5 software license.
 
+"""
+    File driver constants (H5FD*).
+"""
+
 include "config.pxi"
 
 from h5 cimport init_hdf5
diff --git a/h5py/h5g.pyx b/h5py/h5g.pyx
index abeaa91..0faa308 100644
--- a/h5py/h5g.pyx
+++ b/h5py/h5g.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     Low-level HDF5 "H5G" group interface.
 """
@@ -169,18 +169,18 @@ cdef herr_t cb_group_iter(hid_t gid, char *name, void* vis_in) except 2:
 def iterate(GroupID loc not None, object func, int startidx=0, *,
             char* obj_name='.'):
     """ (GroupID loc, CALLABLE func, UINT startidx=0, **kwds)
-        => Return value from func
+    => Return value from func
 
-        Iterate a callable (function, method or callable object) over the
-        members of a group.  Your callable should have the signature::
+    Iterate a callable (function, method or callable object) over the
+    members of a group.  Your callable should have the signature::
 
-            func(STRING name) => Result
+        func(STRING name) => Result
 
-        Returning None continues iteration; returning anything else aborts
-        iteration and returns that value. Keywords:
+    Returning None continues iteration; returning anything else aborts
+    iteration and returns that value. Keywords:
 
-        STRING obj_name (".")
-            Iterate over this subgroup instead
+    STRING obj_name (".")
+        Iterate over this subgroup instead
     """
     if startidx < 0:
         raise ValueError("Starting index must be non-negative")
@@ -361,7 +361,7 @@ cdef class GroupID(ObjectID):
         H5Error is raised if the idx parameter is out-of-range.
         """
         # This function does not properly raise an exception
-        cdef herr_t retval
+        cdef int retval
         retval = H5Gget_objtype_by_idx(self.id, idx)
         if retval < 0:
             raise H5Error("Invalid index")
diff --git a/h5py/h5i.pyx b/h5py/h5i.pyx
index 3d470ed..a700529 100644
--- a/h5py/h5i.pyx
+++ b/h5py/h5i.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     Identifier interface for object inspection.
 """
diff --git a/h5py/h5l.pyx b/h5py/h5l.pyx
index a8c2080..0a2813c 100644
--- a/h5py/h5l.pyx
+++ b/h5py/h5l.pyx
@@ -1,6 +1,4 @@
-
 include "config.pxi"
 
 IF H5PY_18API:
     include "h5l_body.pyx"
-
diff --git a/h5py/h5l_body.pyx b/h5py/h5l_body.pyx
index 0d629d7..e06fb4b 100644
--- a/h5py/h5l_body.pyx
+++ b/h5py/h5l_body.pyx
@@ -9,9 +9,10 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
-    API for the "H5L" family of link-related operations
+    API for the "H5L" family of link-related operations.  When built without
+    1.8 API support, this module exists but is empty.
 """
 
 include "config.pxi"
diff --git a/h5py/h5o.pyx b/h5py/h5o.pyx
index ea42f78..440d39b 100644
--- a/h5py/h5o.pyx
+++ b/h5py/h5o.pyx
@@ -1,4 +1,3 @@
-
 include "config.pxi"
 
 IF H5PY_18API:
diff --git a/h5py/h5o_body.pyx b/h5py/h5o_body.pyx
index 75e2fee..d2bb001 100644
--- a/h5py/h5o_body.pyx
+++ b/h5py/h5o_body.pyx
@@ -10,10 +10,12 @@
 # 
 #-
 
-include "config.pxi"
+"""
+    Module for HDF5 "H5O" functions.  When built without 1.8 API support, this
+    module exists but is empty.
+"""
 
-# Module for the new "H5O" functions introduced in HDF5 1.8.0.  Not even
-# built with API compatibility level below 1.8.
+include "config.pxi"
 
 # Pyrex compile-time imports
 from h5 cimport init_hdf5, ObjectID, SmartStruct
@@ -283,7 +285,7 @@ cdef herr_t cb_obj_simple(hid_t obj, char* name, H5O_info_t *info, void* data) e
 
     cdef _ObjectVisitor visit
 
-    # HDF5 doesn't respect callback return for ".", so skip it
+    # Not all versions of HDF5 respect callback value for ".", so skip it
     if strcmp(name, ".") == 0:
         return 0
 
@@ -326,6 +328,11 @@ def visit(ObjectID loc not None, object func, *,
 
     INT order (h5.ITER_NATIVE)
         Order in which iteration occurs
+
+    Compatibility note:  No callback is executed for the starting path ("."),
+    as some versions of HDF5 don't correctly handle a return value for this
+    case.  This differs from the behavior of the native H5Ovisit, which
+    provides a literal "." as the first value.
     """
     cdef _ObjectVisitor visit = _ObjectVisitor(func)
     cdef H5O_iterate_t cfunc
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index f6329a5..2b2b06e 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     HDF5 property list interface.
 """
diff --git a/h5py/h5r.pyx b/h5py/h5r.pyx
index e2c33fe..e9241be 100644
--- a/h5py/h5r.pyx
+++ b/h5py/h5r.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     H5R API for object and region references.
 """
diff --git a/h5py/h5s.pyx b/h5py/h5s.pyx
index 7649bb0..8f45c86 100644
--- a/h5py/h5s.pyx
+++ b/h5py/h5s.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     Low-level interface to the "H5S" family of data-space functions.
 """
diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index 203dec2..5cc40ab 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -9,7 +9,7 @@
 # $Date$
 # 
 #-
-__doc__ = \
+
 """
     HDF5 "H5T" data-type API
 
@@ -25,7 +25,12 @@ __doc__ = \
        The module function py_create is the complement to this property, and
        is the standard way to translate Numpy dtypes to HDF5 type identifiers.
        Unlike the dtype property, HDF5 datatypes returned by this function are
-       guaranteed to be binary-compatible with their Numpy dtype counterparts
+       guaranteed to be binary-compatible with their Numpy dtype counterparts.
+
+       The function py_create can also create "logically appropriate"
+       destination types; for example, the proper binary representation of
+       a Python string is an opaque type representing a char*, while the
+       "logical" type is an HDF5 variable-length string.
 
     2. Complex numbers
 
@@ -36,25 +41,33 @@ __doc__ = \
        compatible field names, it is treated as a complex type.
 
        The names for complex types are set as a property on the global
-       configuration object, available at "h5py.config".
+       configuration object, available at h5py.get_config().
+
+    3. Boolan types
 
-    3. Enumerated types
+       NumPy booleans are now supported.  They are stored as a 2-value byte
+       enum.  The enum names are set as a property on the global config
+       object, available at h5py.get_config().
 
-       NumPy has no native concept of an enumerated type.  Data of this type
-       will be read from the HDF5 file as integers, depending on the base
-       type of the enum.
+    4. Enumerated types
 
-       You can get at the fields of an enum through the standard HDF5 API
-       calls, which are presented as methods of class TypeEnumID.
-       Additionally, the py_create function allows you to create HDF5
-       enumerated types by passing in a dictionary along with a Numpy dtype.
+       NumPy has no native concept of an enumerated type.  Enumerated types
+       are represented as "hinted" integer types, which are created and
+       tested with the convenience functions h5y.py_create_enum and
+       h5t.py_get_enum.  Values are handled in NumPy as integers.
 
-    4. Variable-length types
+    5. Variable-length types
 
-       "VLEN" datatype objects can be manipulated, but reading and writing data
-       in vlen format is not supported.  This applies to vlen strings as well.
+       Variable-length strings are now supported, via "hinted" object dtypes
+       created and tested with the convenience functions h5t.py_create_vlen
+       and h5t.py_get_vlen.  Currently non-string vlens are not supported.
 
-    5. Datatypes can be pickled if HDF5 1.8.X is available.
+       NOTE:  Only C-style strings are supported; NO embedded nulls are
+       allowed.  This is a limitation of the HDF5 library and won't change
+       until generic vlen support is added.
+
+    6. Datatypes can be pickled if HDF5 1.8.X is available.  The manual
+       HDF5 serialization routines (added in 1.8) are also available.
 """
 
 include "config.pxi"
@@ -1350,7 +1363,7 @@ cdef TypeStringID _c_vlen_str(object basetype):
     return TypeStringID(tid)
 
 cpdef TypeID py_create(object dtype_in, bint logical=0):
-    """(OBJECT dtype_in, DICT enum_vals=None) => TypeID
+    """(OBJECT dtype_in, BOOL logical=False) => TypeID
 
     Given a Numpy dtype object, generate a byte-for-byte memory-compatible
     HDF5 datatype object.  The result is guaranteed to be transient and
@@ -1494,8 +1507,8 @@ cpdef object py_get_vlen(object dt_in):
     return None
 
         
-def path_exists(TypeID src not None, TypeID dst not None):
-
+def _path_exists(TypeID src not None, TypeID dst not None):
+    """ Undocumented and unsupported """
     cdef H5T_cdata_t *data
     cdef H5T_conv_t result = NULL
     
diff --git a/h5py/h5z.pyx b/h5py/h5z.pyx
index c5bc3b2..3c28054 100644
--- a/h5py/h5z.pyx
+++ b/h5py/h5z.pyx
@@ -10,9 +10,8 @@
 # 
 #-
 
-__doc__ = \
 """
-    Filter API and constants
+    Filter API and constants.
 """
 
 include "config.pxi"
diff --git a/h5py/selections.py b/h5py/selections.py
index ff8a216..fb5f9c0 100644
--- a/h5py/selections.py
+++ b/h5py/selections.py
@@ -1,7 +1,19 @@
+#+
+# 
+# This file is part of h5py, a low-level Python interface to the HDF5 library.
+# 
+# Copyright (C) 2008 Andrew Collette
+# http://h5py.alfven.org
+# License: BSD  (See LICENSE.txt for full license)
+# 
+# $Date$
+# 
+#-
 
 """
     High-level access to HDF5 dataspace selections
 """
+
 import numpy as np
 
 from h5py import h5s

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git



More information about the debian-science-commits mailing list