[h5py] 93/455: Setup, docs and h5p improvements

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:21 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 fd96ab058ad77099895e9e4e436db5f0de1947b7
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Fri Aug 1 01:32:35 2008 +0000

    Setup, docs and h5p improvements
---
 MANIFEST.in            |  3 ++-
 docs/API.html          |  9 +++++++
 docs/Manual.html       |  9 +++++++
 h5py/h5fd.pxd          | 13 ++++++++++
 h5py/h5fd.pyx          | 10 ++++++++
 h5py/h5p.pxd           |  9 +++++--
 h5py/h5p.pyx           | 67 +++++++++++++++++++++++++++++++++++++++++++++++---
 h5py/tests/__init__.py | 42 +++++++++++++++++++++++--------
 setup.py               | 26 +++++++++++++-------
 9 files changed, 163 insertions(+), 25 deletions(-)

diff --git a/MANIFEST.in b/MANIFEST.in
index 1ade80a..21fec11 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -6,5 +6,6 @@ include CHANGES.txt
 include docs.cfg
 recursive-include h5py *.py *.pyx *.pxd *.pxi *.h *.c *.hdf5
 recursive-include licenses *
-recursive-include docs *
+recursive-include docs/html *
+include docs/API.html
 
diff --git a/docs/API.html b/docs/API.html
new file mode 100644
index 0000000..8171c2f
--- /dev/null
+++ b/docs/API.html
@@ -0,0 +1,9 @@
+<html>
+<!-- Redirect so the user doesn't have to manually find index.html -->
+<head>
+<title>h5py API Documentation</title>
+<meta http-equiv="REFRESH" content="0; url=api-html/index.html"></HEAD>
+<body>
+Redirecting to <a href="api-html/index.html">API docs index</a> in HTML folder...
+</body>
+</html>
diff --git a/docs/Manual.html b/docs/Manual.html
new file mode 100644
index 0000000..5aa52f7
--- /dev/null
+++ b/docs/Manual.html
@@ -0,0 +1,9 @@
+<html>
+<!-- Redirect so the user doesn't have to manually find index.html -->
+<head>
+<title>h5py Documentation</title>
+<meta http-equiv="REFRESH" content="0; url=manual-html/index.html"></HEAD>
+<body>
+Redirecting to <a href="manual-html/index.html">index</a> in HTML folder...
+</body>
+</html>
diff --git a/h5py/h5fd.pxd b/h5py/h5fd.pxd
index 1accb19..a4dcfc9 100644
--- a/h5py/h5fd.pxd
+++ b/h5py/h5fd.pxd
@@ -13,6 +13,8 @@
 # This file contains code or comments from the HDF5 library.  See the file
 # licenses/hdf5.txt for the full HDF5 software license.
 
+include "std_defs.pxi"
+
 cdef extern from "hdf5.h":
 
   ctypedef enum H5FD_mem_t:
@@ -26,6 +28,17 @@ cdef extern from "hdf5.h":
     H5FD_MEM_OHDR       = 6,
     H5FD_MEM_NTYPES
 
+  # HDF5 uses a clever scheme wherein these are actually init() calls
+  # Hopefully Pyrex won't have a problem with this.
+  # Thankfully they are defined but -1 if unavailable
+  hid_t H5FD_CORE
+  hid_t H5FD_FAMILY
+# hid_t H5FD_GASS  not in 1.8.X
+  hid_t H5FD_LOG
+  hid_t H5FD_MPIO
+  hid_t H5FD_MULTI
+  hid_t H5FD_SEC2
+  hid_t H5FD_STDIO  
 
   int H5FD_LOG_LOC_READ   # 0x0001
   int H5FD_LOG_LOC_WRITE  # 0x0002
diff --git a/h5py/h5fd.pyx b/h5py/h5fd.pyx
index bd5420d..fe234e9 100644
--- a/h5py/h5fd.pyx
+++ b/h5py/h5fd.pyx
@@ -24,6 +24,16 @@ MEM_LHEAP = H5FD_MEM_LHEAP
 MEM_OHDR = H5FD_MEM_OHDR
 MEM_NTYPES = H5FD_MEM_NTYPES
 
+# === Driver types ============================================================
+
+CORE = H5FD_CORE
+FAMILY = H5FD_FAMILY
+LOG = H5FD_LOG
+MPIO = H5FD_MPIO
+MULTI = H5FD_MULTI
+SEC2 = H5FD_SEC2
+STDIO = H5FD_STDIO  
+
 # === Logging driver ==========================================================
 
 LOG_LOC_READ  = H5FD_LOG_LOC_READ   # 0x0001
diff --git a/h5py/h5p.pxd b/h5py/h5p.pxd
index e23146f..0d2be85 100644
--- a/h5py/h5p.pxd
+++ b/h5py/h5p.pxd
@@ -154,6 +154,13 @@ cdef extern from "hdf5.h":
   herr_t    H5Pset_fapl_log(hid_t fapl_id, char *logfile, unsigned int flags, size_t buf_size) except *
   herr_t    H5Pset_fapl_multi(hid_t fapl_id, H5FD_mem_t *memb_map, hid_t *memb_fapl,
                 char **memb_name, haddr_t *memb_addr, hbool_t relax) 
+  herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, int rdcc_nelmts,
+                      size_t rdcc_nbytes, double rdcc_w0) except *
+  herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, int *rdcc_nelmts,
+                      size_t *rdcc_nbytes, double *rdcc_w0) except *
+  herr_t H5Pset_fapl_sec2(hid_t fapl_id) except *
+  herr_t H5Pset_fapl_stdio(hid_t fapl_id) except *
+  hid_t  H5Pget_driver(hid_t fapl_id) except *
 
   # Dataset creation properties
   herr_t        H5Pset_layout(hid_t plist, int layout) except *
@@ -191,8 +198,6 @@ cdef extern from "hdf5.h":
   H5Z_EDC_t H5Pget_edc_check(hid_t plist) except *
 
   # Other properties
-  herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, int rdcc_nelmts,
-                      size_t rdcc_nbytes, double rdcc_w0) except *
   herr_t H5Pset_sieve_buf_size(hid_t fapl_id, hsize_t size) except *
   herr_t H5Pset_fapl_log(hid_t fapl_id, char *logfile,
                          unsigned int flags, size_t buf_size) except *
diff --git a/h5py/h5p.pyx b/h5py/h5p.pyx
index 52d49c8..19c5f7d 100644
--- a/h5py/h5p.pyx
+++ b/h5py/h5p.pyx
@@ -140,7 +140,7 @@ cdef class PropInstanceID(PropID):
 cdef class PropFCID(PropInstanceID):
 
     """
-        Represents a file creation property list.
+        File creation property list.
     """
 
     def get_version(self):
@@ -243,7 +243,7 @@ cdef class PropFCID(PropInstanceID):
 cdef class PropDCID(PropInstanceID):
 
     """
-        Represents a dataset creation property list.
+        Dataset creation property list.
     """
 
     def set_layout(self, int layout_code):
@@ -459,6 +459,7 @@ cdef class PropDCID(PropInstanceID):
         nelements = 16 # HDF5 library actually complains if this is too big.
 
         if not self._has_filter(filter_code):
+            # Avoid library segfault
             return None
 
         retval = H5Pget_filter_by_id(self.id, <H5Z_filter_t>filter_code,
@@ -509,7 +510,7 @@ cdef class PropDCID(PropInstanceID):
 cdef class PropFAID(PropInstanceID):
 
     """
-        Represents a file access property list
+        File access property list
     """
 
     def set_fclose_degree(self, int close_degree):
@@ -602,6 +603,66 @@ cdef class PropFAID(PropInstanceID):
         """
         H5Pset_fapl_log(self.id, logfile, flags, buf_size)
 
+    def set_fapl_sec2(self):
+        """ ()
+
+            Select the "section-2" driver (h5fd.SEC2).
+        """
+        H5Pset_fapl_sec2(self.id)
+
+    def set_fapl_stdio(self):
+        """ ()
+
+            Select the "stdio" driver (h5fd.STDIO)
+        """
+        H5Pset_fapl_stdio(self.id)
+
+    def get_driver(self):
+        """ () => INT driver code
+
+            Return an integer identifier for the driver used by this list.
+            Although HDF5 implements these as full-fledged objects, they are
+            treated as integers by Python.  Built-in drivers identifiers are
+            listed in module h5fd; they are:
+                CORE
+                FAMILY
+                LOG
+                MPIO
+                MULTI
+                SEC2
+                STDIO
+        """
+        return H5Pget_driver(self.id)
+
+    def set_cache(self, int mdc, int rdcc, size_t rdcc_nbytes, double rdcc_w0):
+        """ (INT mdc, INT rdcc, UINT rdcc_nbytes, DOUBLE rdcc_w0)
+
+            Set the metadata (mdc) and raw data chunk (rdcc) cache properties.
+            See the HDF5 docs for a full explanation.
+        """
+        H5Pset_cache(self.id, mdc, rdcc, rdcc_nbytes, rdcc_w0)
+
+    def get_cache(self):
+        """ () => TUPLE cache info
+
+            Get the metadata and raw data chunk cache settings.  See the HDF5
+            docs for element definitions.  Return is a 4-tuple with entries:
+
+            1. INT mdc              Number of metadata objects
+            2. INT rdcc             Number of raw data chunks
+            3. UINT rdcc_nbytes     Size of raw data cache
+            4. DOUBLE rdcc_w0       Preemption policy for data cache.
+        """
+        cdef int mdc, rdcc
+        cdef size_t rdcc_nbytes
+        cdef double w0
+
+        H5Pget_cache(self.id, &mdc, &rdcc, &rdcc_nbytes, &w0)
+        return (mdc, rdcc, rdcc_nbytes, w0)
+
+
+
+
 
 
 
diff --git a/h5py/tests/__init__.py b/h5py/tests/__init__.py
index f9e91a5..e4dc9c4 100644
--- a/h5py/tests/__init__.py
+++ b/h5py/tests/__init__.py
@@ -19,29 +19,51 @@ import test_h5a, test_h5d, test_h5f, \
 
 from h5py import *
 
-TEST_CASES = (test_h5a.TestH5A, test_h5d.TestH5D, test_h5f.TestH5F, 
-              test_h5g.TestH5G, test_h5i.TestH5I, test_h5p.TestH5P,
-              test_h5s.TestH5S, test_h5t.TestH5T, test_h5.TestH5,
-              test_highlevel.TestFile, test_highlevel.TestDataset,
-              test_highlevel.TestGroup, test_threads.TestThreads)
+sections = {'h5a': test_h5a.TestH5A, 'h5d': test_h5d.TestH5D,
+            'h5f': test_h5f.TestH5F, 'h5g': test_h5g.TestH5G,
+            'h5i': test_h5i.TestH5I, 'h5p': test_h5p.TestH5P,
+            'h5s': test_h5s.TestH5S, 'h5t': test_h5t.TestH5T,
+            'h5': test_h5.TestH5,
+            'File': test_highlevel.TestFile,
+            'Group': test_highlevel.TestGroup,
+            'Dataset': test_highlevel.TestDataset,
+            'threads': test_threads.TestThreads }
 
-def buildsuite(cases):
+order = ('h5a', 'h5d', 'h5f', 'h5g', 'h5i', 'h5p', 'h5s', 'h5', 'File', 'Group',
+         'Dataset', 'threads')
 
+def buildsuite(cases):
+    """ cases should be an iterable of TestCase subclasses """
     loader = unittest.TestLoader()
     suite = unittest.TestSuite()
     for test_case in cases:
         suite.addTests(loader.loadTestsFromTestCase(test_case))
     return suite
 
-def runtests():
-    suite = buildsuite(TEST_CASES)
+def runtests(requests=None):
+    if requests is None:
+        requests = ()
+    excluded = [x[1:] for x in requests if len(x) >=2 and x.find('-') == 0]
+    included = [x for x in requests if x.find('-') != 0]
+
+    cases = order if len(included) is 0 else included
+    cases = [x for x in cases if x not in excluded]
+    try:
+        cases = [sections[x] for x in cases]
+    except KeyError, e:
+        raise RuntimeError('Test "%s" is unknown' % e.args[0])
+
+    suite = buildsuite(cases)
     retval = unittest.TextTestRunner(verbosity=3).run(suite)
     print "=== Tested HDF5 %s (%s API) ===" % (h5.hdf5_version, h5.api_version)
     return retval.wasSuccessful()
 
 def autotest():
-    if not runtests():
-        sys.exit(1)
+    try:
+        if not runtests():
+            sys.exit(1)
+    except:
+        sys.exit(2)
 
 
 
diff --git a/setup.py b/setup.py
index b4d5897..2560c27 100644
--- a/setup.py
+++ b/setup.py
@@ -280,10 +280,11 @@ for module in modules:
 
 class test(Command):
     description = "Build %s and run unit tests" % NAME
-    user_options = []
+    user_options = [('sections=','s','Comma separated list of tests ("-" prefix to NOT run)')]
 
     def initialize_options(self):
-        pass
+        self.sections = None
+
     def finalize_options(self):
         pass
 
@@ -294,7 +295,7 @@ class test(Command):
         try:
             sys.path = [op.abspath(buildobj.build_lib)] + oldpath
             import h5py.tests
-            if not h5py.tests.runtests():
+            if not h5py.tests.runtests(None if self.sections is None else tuple(self.sections.split(','))):
                 raise DistutilsError("Unit tests failed.")
         finally:
             sys.path = oldpath
@@ -317,7 +318,7 @@ class dev(Command):
 
     def run(self):
         if self.clean:
-            for x in ('build','docs/html'):
+            for x in ('build','docs/api-html', 'docs/manual-html'):
                 try:
                     shutil.rmtree(x)
                 except OSError:
@@ -335,15 +336,22 @@ class dev(Command):
         if self.doc:
             buildobj = self.distribution.get_command_obj('build')
             buildobj.run()
-            if not op.exists('docs/html'):
-                os.mkdir('docs', 0755)
-                os.mkdir('docs/html', 0755)
+            for x in ('docs', 'docs/api-html'):
+                if not op.exists(x):
+                    os.mkdir(x, 0755)
 
             retval = os.spawnlp(os.P_WAIT, 'epydoc', '-q', '--html',
-                        '-o', 'docs/html', '--config', 'docs.cfg', 
+                        '-o', 'docs/api-html', '--config', 'docs.cfg', 
                         os.path.join(buildobj.build_lib, NAME) )
             if retval != 0:
-                raise DistutilsExecError("Could not run epydoc to build documentation.")
+                warn("Could not run epydoc to build documentation.")
+
+
+            retval = os.system("cd docs; make html")
+            if retval != 0:
+                warn("Could not run Sphinx doc generator")
+            else:
+                shutil.copytree('docs/build/html', 'docs/manual-html')
 
         if self.readme:
             import docutils.core

-- 
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