[h5py] 09/455: iterate() return val is confusing and useless

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:12 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 d5809aa8bb5f00887760a3da7468a72c92ebe7ee
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Tue May 6 23:31:50 2008 +0000

    iterate() return val is confusing and useless
---
 h5py/h5a.pyx           | 6 +-----
 h5py/h5g.pyx           | 4 ----
 h5py/tests/test_h5a.py | 9 +++------
 h5py/tests/test_h5g.py | 9 +++------
 4 files changed, 7 insertions(+), 21 deletions(-)

diff --git a/h5py/h5a.pyx b/h5py/h5a.pyx
index dcc786a..e4460fc 100755
--- a/h5py/h5a.pyx
+++ b/h5py/h5a.pyx
@@ -212,8 +212,7 @@ def iterate(hid_t loc_id, object func, object data=None, unsigned int startidx=0
 
         Iterate an arbitrary Python function over the attributes attached
         to an object.  You can also start at an arbitrary attribute by
-        specifying its (zero-based) index.  The return value is the index of 
-        the last attribute processed.
+        specifying its (zero-based) index.
 
         Your function:
         1.  Should accept three arguments: the (INT) id of the parent object, 
@@ -230,14 +229,11 @@ def iterate(hid_t loc_id, object func, object data=None, unsigned int startidx=0
     int_tpl = (func, data,[])
 
     retval = H5Aiterate(loc_id, &i, <H5A_operator_t>iter_cb, int_tpl)
-    if retval == 1:
-        i = i - 1  # user bailed out
 
     if retval < 0:
         if len(int_tpl[2]) != 0:
             raise int_tpl[2][0]
         raise H5AttributeError("Error occured during iteration")
-    return i-1
 
 # === Python extensions =======================================================
 
diff --git a/h5py/h5g.pyx b/h5py/h5g.pyx
index 770278f..d792fc6 100755
--- a/h5py/h5g.pyx
+++ b/h5py/h5g.pyx
@@ -280,14 +280,10 @@ def iterate(hid_t loc_id, char* name, object func, object data=None, int startid
 
     retval = H5Giterate(loc_id, name, &i, <H5G_iterate_t>iter_cb_helper, int_tpl)
 
-    if retval == 1:  # user bailed out
-        i = i -1
-
     if retval < 0:
         if len(int_tpl[2]) != 0:
             raise int_tpl[2][0]
         raise GroupError("Error occured during iteration")
-    return i-1
 
 # === Custom extensions =======================================================
 
diff --git a/h5py/tests/test_h5a.py b/h5py/tests/test_h5a.py
index 22be4e5..d92b247 100755
--- a/h5py/tests/test_h5a.py
+++ b/h5py/tests/test_h5a.py
@@ -160,23 +160,20 @@ class TestH5A(unittest.TestCase):
             namelist.append(name)
 
         namelist = []
-        n = h5a.iterate(self.obj, iterate_all, namelist)
+        h5a.iterate(self.obj, iterate_all, namelist)
         self.assertEqual(namelist, ATTRIBUTES_ORDER)
-        self.assertEqual(n, len(ATTRIBUTES_ORDER)-1)
 
         namelist = []
-        n = h5a.iterate(self.obj, iterate_two, namelist)
+        h5a.iterate(self.obj, iterate_two, namelist)
         self.assertEqual(namelist, ATTRIBUTES_ORDER[0:2])
-        self.assertEqual(n, 1)
 
         namelist = []
         self.assertRaises(RuntimeError, h5a.iterate, self.obj, iterate_fault, namelist)
         self.assertEqual(namelist, ATTRIBUTES_ORDER[0:2])
         
         namelist = []
-        n = h5a.iterate(self.obj, iterate_two, namelist, 1)
+        h5a.iterate(self.obj, iterate_two, namelist, 1)
         self.assertEqual(namelist, ATTRIBUTES_ORDER[1:3])
-        self.assertEqual(n, 2)
 
 
     # === Python extensions ===================================================
diff --git a/h5py/tests/test_h5g.py b/h5py/tests/test_h5g.py
index 89fc142..1bce6f5 100644
--- a/h5py/tests/test_h5g.py
+++ b/h5py/tests/test_h5g.py
@@ -135,23 +135,20 @@ class TestH5G(unittest.TestCase):
             namelist.append(name)
 
         namelist = []
-        n = h5g.iterate(self.obj, '.', iterate_all, namelist)
+        h5g.iterate(self.obj, '.', iterate_all, namelist)
         self.assertEqual(namelist, TEST_GROUPS)
-        self.assertEqual(n, len(TEST_GROUPS)-1)
 
         namelist = []
-        n = h5g.iterate(self.obj, '.', iterate_two, namelist)
+        h5g.iterate(self.obj, '.', iterate_two, namelist)
         self.assertEqual(namelist, TEST_GROUPS[0:2])
-        self.assertEqual(n, 1)
 
         namelist = []
         self.assertRaises(RuntimeError, h5g.iterate, self.obj, '.', iterate_fault, namelist)
         self.assertEqual(namelist, TEST_GROUPS[0:2])
         
         namelist = []
-        n = h5g.iterate(self.obj, '.', iterate_two, namelist, 1)
+        h5g.iterate(self.obj, '.', iterate_two, namelist, 1)
         self.assertEqual(namelist, TEST_GROUPS[1:3])
-        self.assertEqual(n, 2)
 
     def test_py_listnames(self):
 

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