[h5py] 313/455: Fix enum glitch

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 17b192497c4d43ccbe91b1f907a8e150d6f69cd4
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Wed Sep 30 02:51:30 2009 +0000

    Fix enum glitch
---
 h5py/h5t.pyx           |  2 +-
 h5py/tests/test_h5t.py | 19 +++++++++++++------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/h5py/h5t.pyx b/h5py/h5t.pyx
index 462be12..eca7475 100644
--- a/h5py/h5t.pyx
+++ b/h5py/h5t.pyx
@@ -1445,7 +1445,7 @@ cpdef TypeID py_create(object dtype_in, bint logical=0):
     finally:
         phil.release()
 
-cpdef dtype py_new_enum(dtype dt_in, dict enum_vals):
+cpdef dtype py_new_enum(object dt_in, dict enum_vals):
     """ (DTYPE dt_in, DICT enum_vals) => DTYPE
 
     Create a new NumPy integer dtype, which contains "hint" metadata for
diff --git a/h5py/tests/test_h5t.py b/h5py/tests/test_h5t.py
index 268ca95..48714d3 100644
--- a/h5py/tests/test_h5t.py
+++ b/h5py/tests/test_h5t.py
@@ -462,25 +462,32 @@ class TestPyCreate(TestCasePlus):
     def test_enum(self):
         """ Enum type translation
 
+        Literal:
+        - TypeIntegerID
+
+        Logical:
         - TypeEnumID
         - Base TypeIntegerID
-        - 0 to (at least) 1000 values
+        - 0 to (at least) 128 values
         """
-        enums = [{}, {'a': 0, 'b': 1}, dict(("%s" % d, d) for d in xrange(1000)) ]
+        enums = [{}, {'a': 0, 'b': 1}, dict(("%s" % d, d) for d in xrange(128)) ]
         bases = ('|i1', '|u1', '<i4', '>i4', '<u8')
 
         for b in bases:
             for e in enums:
                 dt = h5t.py_new_enum(b, e)
-                htype = h5t.py_create(dt)
                 htype_comp = h5t.py_create(b)
-                self.assert_(isinstance(htype, h5t.TypeEnumID))
-                basetype = h5t.get_super()
+                htype = h5t.py_create(dt)
+                self.assert_(isinstance(htype, h5t.TypeIntegerID))
+                self.assertEqual(htype, htype_comp)
+                htype = h5t.py_create(dt, logical=True)
+                self.assert_(isinstance(htype, h5t.TypeEnumID), "%s" % (htype,))
+                basetype = htype.get_super()
                 self.assertEqual(htype_comp, basetype)
                 self.assertEqual(htype.get_nmembers(), len(e))
                 for idx in xrange(htype.get_nmembers()):
                     name = htype.get_member_name(idx)
-                    val = htype.get_member_value(idx)
+                    value = htype.get_member_value(idx)
                     self.assertEqual(e[name], value)
 
 

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