[h5py] 441/455: Port tests

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:59 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 82af2e4b5398b8c7d7d5649bdaa3f8f1320fa81f
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Sun Mar 7 22:54:57 2010 +0000

    Port tests
---
 h5py/tests/test_h5t.py         | 98 ------------------------------------------
 h5py/tests/types/__init__.py   |  9 ++++
 h5py/tests/types/test_types.py | 74 +++++++++++++++++++++++++++++++
 3 files changed, 83 insertions(+), 98 deletions(-)

diff --git a/h5py/tests/test_h5t.py b/h5py/tests/test_h5t.py
index ddfd1cb..aa3e1a4 100644
--- a/h5py/tests/test_h5t.py
+++ b/h5py/tests/test_h5t.py
@@ -207,64 +207,6 @@ class TestPyCreate(TestCasePlus):
         Tests the translation from Python dtypes to HDF5 datatypes
     """
 
-    def test_integer(self):
-        """ Signed integer translation
-
-        - TypeIntegerID
-        - 1, 2, 4, 8 bytes
-        - LE and BE
-        - Signed
-        """
-        bases = ('=i', '<i', '>i')
-
-        for b in bases:
-            for l in (1, 2, 4, 8):
-                dt = '%s%s' % (b, l)
-                htype = h5t.py_create(dt)
-                self.assert_(isinstance(htype, h5t.TypeIntegerID), "wrong class")
-                self.assertEqual(htype.get_size(), l, "wrong size")
-                self.assertEqual(htype.get_sign(), h5t.SGN_2, "wrong sign")
-                if l != 1:  # NumPy does not allow ordering of 1-byte types
-                    self.assertEqual(htype.get_order(), bytemap[b[0]])
-
-    def test_uinteger(self):
-        """ Unsigned integer translation
-
-        - TypeIntegerID
-        - 1, 2, 4, 8 bytes
-        - LE and BE
-        - Unsigned
-        """
-        bases = ('=u', '<u', '>u')
-
-        for b in bases:
-            for l in (1, 2, 4, 8):
-                dt = "%s%s" % (b, l)
-                htype = h5t.py_create(dt)
-                self.assert_(isinstance(htype, h5t.TypeIntegerID), "wrong class")
-                self.assertEqual(htype.get_size(), l, "wrong size")
-                self.assertEqual(htype.get_sign(), h5t.SGN_NONE, "wrong sign")
-                if l != 1:
-                    self.assertEqual(htype.get_order(), bytemap[b[0]], "wrong order")
-
-    def test_float(self):
-        """ Floating-point translation
-
-        - TypeFloatID
-        - 1, 2, 4, 8 bytes
-        - LE and BE
-        - Unsigned
-        """
-        bases = ('=f', '<f', '>f')
-        
-        for b in bases:
-            for l in (4, 8):
-                dt = "%s%s" % (b, l)
-                htype = h5t.py_create(dt)
-                self.assert_(isinstance(htype, h5t.TypeFloatID), "wrong class")
-                self.assertEqual(htype.get_size(), l, "wrong size")
-                self.assertEqual(htype.get_order(), bytemap[b[0]])
-
     def test_complex(self):
         """ Complex type translation
 
@@ -291,49 +233,9 @@ class TestPyCreate(TestCasePlus):
                     self.assertEqual(st.get_size(), l//2)
                     self.assertEqual(st.get_order(), bytemap[b[0]])
 
-    def test_string(self):
-        """ Fixed-length string translation
 
-        - TypeStringID
-        - Fixed-length
-        - Size 1 byte to 2**31-1 bytes
-        - Charset ASCII
-        - Null-padded
-        """
 
-        for l in (1, 23, 2**31-1):
-            dt = '|S%s' % l
-            htype = h5t.py_create(dt)
-            self.assert_(isinstance(htype, h5t.TypeStringID), "wrong class")
-            self.assertEqual(htype.get_size(), l)
-            self.assertEqual(htype.get_cset(), h5t.CSET_ASCII, "wrong cset")
-            self.assertEqual(htype.get_strpad(), h5t.STR_NULLPAD, "wrong padding")
-            self.assert_(not htype.is_variable_str(), "should be fixed str")
 
-    def test_vlstring(self):
-        """ Variable-length string translation
-
-        In literal mode:
-        - TypeOpaqueID
-        - Equal to PYTHON_OBJECT
-
-        In logical mode:
-        - TypeStringID
-        - Variable-length
-        - Charset ASCII
-        - Null-terminated
-        """
-
-        dt = h5t.py_new_vlen(str)
-        htype = h5t.py_create(dt)
-        self.assert_(isinstance(htype, h5t.TypeOpaqueID))
-        self.assertEqual(htype, h5t.PYTHON_OBJECT)
-
-        htype = h5t.py_create(dt, logical=True)
-        self.assert_(isinstance(htype, h5t.TypeStringID))
-        self.assert_(htype.is_variable_str())
-        self.assertEqual(htype.get_cset(), h5t.CSET_ASCII)
-        self.assertEqual(htype.get_strpad(), h5t.STR_NULLTERM)
 
     def test_boolean(self):
         """ Boolean type translation
diff --git a/h5py/tests/types/__init__.py b/h5py/tests/types/__init__.py
new file mode 100644
index 0000000..5294b56
--- /dev/null
+++ b/h5py/tests/types/__init__.py
@@ -0,0 +1,9 @@
+
+"""
+    Type and data-conversion test package.
+
+    Tests the following:
+
+    1) HDF5 to NumPy type mapping
+    2) Data conversion
+"""
diff --git a/h5py/tests/types/test_types.py b/h5py/tests/types/test_types.py
new file mode 100644
index 0000000..6ef3810
--- /dev/null
+++ b/h5py/tests/types/test_types.py
@@ -0,0 +1,74 @@
+
+"""
+    Test NumPy dtype to HDF5 type conversion.
+"""
+
+import numpy as np
+from h5py import tests, h5t
+
+class TestIntegers(tests.HTest):
+
+    def test_int(self):
+        """ (Types) Integer dtype to HDF5 literal """
+        htype = h5t.py_create('i')
+        self.assertIsInstance(htype, h5t.TypeIntegerID)
+
+    def test_int_log(self):
+        """ (Types) Integer dtype to HDF5 logical """
+        htype = h5t.py_create('i', logical=True)
+        self.assertIsInstance(htype, h5t.TypeIntegerID)
+
+class TestFloats(tests.HTest):
+
+    def test_float(self):
+        """ (Types) Float dtype to HDF5 literal """
+        htype = h5t.py_create('f')
+        self.assertIsInstance(htype, h5t.TypeFloatID)
+
+    def test_float_log(self):
+        """ (Types) Float dtype to HDF5 logical """
+        htype = h5t.py_create('f', logical=True)
+
+class TestString(tests.HTest):
+
+    def test_string(self):
+        """ (Types) String dtype to HDF5 literal """
+        htype = h5t.py_create('S10')
+        self.assertIsInstance(htype, h5t.TypeStringID)
+        self.assertEqual(htype.get_size(), 10)
+
+    def test_string(self):
+        """ (Types) String dtype to HDF5 logical """
+        htype = h5t.py_create('S10', logical=True)
+        self.assertIsInstance(htype, h5t.TypeStringID)
+        self.assertEqual(htype.get_size(), 10)
+
+    def test_string(self):
+        """ (Types) Length-1 string works OK """
+        htype = h5t.py_create('S1')
+        self.assertIsInstance(htype, h5t.TypeStringID)
+        self.assertEqual(htype.get_size(), 1)
+
+    def test_vlstring_lit(self):
+        """ (Types) Vlen string literal is Python object pointer """
+        dt = h5t.special_dtype(vlen=str)
+        htype = h5t.py_create(dt)
+        self.assertIsInstance(htype, h5t.TypeOpaqueID)
+        self.assertEqual(htype, h5t.PYTHON_OBJECT)
+
+    def test_vlstring_log(self):
+        """ (Types) Vlen string logical is null-term HDF5 vlen ASCII string """
+        dt = h5t.special_dtype(vlen=str)
+        htype = h5t.py_create(dt, logical=True)
+        self.assertIsInstance(htype, h5t.TypeStringID)
+        self.assertEqual(htype.is_variable_str(), True)
+        self.assertEqual(htype.get_cset(), h5t.CSET_ASCII)
+        self.assertEqual(htype.get_strpad(), h5t.STR_NULLTERM)
+
+
+
+
+
+
+
+

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