[h5py] 28/38: Fix lint issues with _hl/dims

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


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

ghisvail-guest pushed a commit to branch master
in repository h5py.

commit 3837f9f2b8079e0d01df5253252522185744f7a8
Author: Andrew Collette <andrew.collette at gmail.com>
Date:   Sat May 30 18:39:34 2015 -0600

    Fix lint issues with _hl/dims
---
 h5py/_hl/dims.py | 59 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 file changed, 44 insertions(+), 15 deletions(-)

diff --git a/h5py/_hl/dims.py b/h5py/_hl/dims.py
index 2afde6b..91ad0b5 100644
--- a/h5py/_hl/dims.py
+++ b/h5py/_hl/dims.py
@@ -7,21 +7,28 @@
 # License:  Standard 3-clause BSD; see "license.txt" for full license terms
 #           and contributor agreement.
 
-from __future__ import absolute_import
+"""
+    Implements support for HDF5 dimension scales.
+"""
 
-import numpy
+from __future__ import absolute_import
 
 from .. import h5ds
 from . import base
 from .base import phil, with_phil
-from .dataset import Dataset, readtime_dtype
+from .dataset import Dataset
 
 
 class DimensionProxy(base.CommonStateObject):
 
+    """
+        Represents an HDF5 "dimension".
+    """
+    
     @property
     @with_phil
     def label(self):
+        """ Get or set the dimension scale label """
         #return h5ds.get_label(self._id, self._dimension)
         # Produces a segfault for a non-existent label (Fixed in hdf5-1.8.8).
         # Here is a workaround:
@@ -33,11 +40,12 @@ class DimensionProxy(base.CommonStateObject):
     @label.setter
     @with_phil
     def label(self, val):
+        # pylint: disable=missing-docstring
         h5ds.set_label(self._id, self._dimension, self._e(val))
 
     @with_phil
-    def __init__(self, id, dimension):
-        self._id = id
+    def __init__(self, id_, dimension):
+        self._id = id_
         self._dimension = dimension
 
     @with_phil
@@ -59,39 +67,50 @@ class DimensionProxy(base.CommonStateObject):
 
     @with_phil
     def __getitem__(self, item):
+    
         if isinstance(item, int):
             scales = []
-            def f(dsid):
-                scales.append(Dataset(dsid))
-            h5ds.iterate(self._id, self._dimension, f, 0)
-            return scales[item]
+            h5ds.iterate(self._id, self._dimension, scales.append, 0)
+            return Dataset(scales[item])
+            
         else:
             def f(dsid):
+                """ Iterate over scales to find a matching name """
                 if h5ds.get_scale_name(dsid) == self._e(item):
-                    return Dataset(dsid)
+                    return dsid
+                    
             res = h5ds.iterate(self._id, self._dimension, f, 0)
             if res is None:
                 raise KeyError('%s not found' % item)
-            return res
+            return Dataset(res)
 
     def attach_scale(self, dset):
+        """ Attach a scale to this dimension.
+        
+        Provide the Dataset of the scale you would like to attach.
+        """
         with phil:
             h5ds.attach_scale(self._id, dset.id, self._dimension)
 
     def detach_scale(self, dset):
+        """ Remove a scale from this dimension.
+        
+        Provide the Dataset of the scale you would like to remove.
+        """
         with phil:
             h5ds.detach_scale(self._id, dset.id, self._dimension)
 
     def items(self):
+        """ Get a list of (name, Dataset) pairs with all scales on this
+        dimension.
+        """
         with phil:
             scales = []
-            def f(dsid):
-                scales.append(dsid)
-            
+
             # H5DSiterate raises an error if there are no dimension scales,
             # rather than iterating 0 times.  See #483.
             if len(self) > 0:
-                h5ds.iterate(self._id, self._dimension, f, 0)
+                h5ds.iterate(self._id, self._dimension, scales.append, 0)
                 
             return [
                 (self._d(h5ds.get_scale_name(id)), Dataset(id))
@@ -99,10 +118,12 @@ class DimensionProxy(base.CommonStateObject):
                 ]
 
     def keys(self):
+        """ Get a list of names for the scales on this dimension. """
         with phil:
             return [key for (key, val) in self.items()]
 
     def values(self):
+        """ Get a list of Dataset for scales on this dimension. """
         with phil:
             return [val for (key, val) in self.items()]
 
@@ -117,6 +138,10 @@ class DimensionProxy(base.CommonStateObject):
 class DimensionManager(base.MappingHDF5, base.CommonStateObject):
 
     """
+        Represents a collection of dimension associated with a dataset.
+        
+        Like AttributeManager, an instance of this class is returned when
+        accessing the ".dims" property on a Dataset.
     """
 
     @with_phil
@@ -151,5 +176,9 @@ class DimensionManager(base.MappingHDF5, base.CommonStateObject):
         return "<Dimensions of HDF5 object at %s>" % id(self._id)
 
     def create_scale(self, dset, name=''):
+        """ Create a new dimension, from an initial scale.
+        
+        Provide the dataset and a name for the scale.
+        """
         with phil:
             h5ds.set_scale(dset.id, self._e(name))

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