[h5py] 442/455: Add 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 a6a5819092d9d55ae16f823d3cd071e7ea6b2e67
Author: andrewcollette <andrew.collette at gmail.com>
Date: Tue Mar 9 23:34:56 2010 +0000
Add tests
---
h5py/tests/high/test_dataset.py | 17 --------
h5py/tests/types/test_conv.py | 14 +++++++
h5py/tests/types/test_types.py | 87 ++++++++++++++++++++++++++++++++++++++++-
3 files changed, 100 insertions(+), 18 deletions(-)
diff --git a/h5py/tests/high/test_dataset.py b/h5py/tests/high/test_dataset.py
index fa5cee7..2d8e734 100644
--- a/h5py/tests/high/test_dataset.py
+++ b/h5py/tests/high/test_dataset.py
@@ -16,23 +16,6 @@ class Base(tests.HTest):
self.f.close()
os.unlink(self.name)
-class TestTypes(Base):
-
- def test_array_dtype(self):
- """ (Dataset) Array dtypes using non-tuple shapes """
- dt1 = np.dtype('f4', (2,))
- dt2 = np.dtype('f4', [2])
- dt3 = np.dtype('f4', 2)
- dt4 = np.dtype('f4', 2.1)
- ds1 = self.f.create_dataset('ds1', (1,), dt1)
- ds2 = self.f.create_dataset('ds2', (1,), dt2)
- ds3 = self.f.create_dataset('ds3', (1,), dt3)
- ds4 = self.f.create_dataset('ds4', (1,), dt4)
- self.assertEqual(ds1.dtype, dt1)
- self.assertEqual(ds2.dtype, dt1)
- self.assertEqual(ds3.dtype, dt1)
- self.assertEqual(ds4.dtype, dt1)
-
class TestArray(Base):
def test_array(self):
diff --git a/h5py/tests/types/test_conv.py b/h5py/tests/types/test_conv.py
new file mode 100644
index 0000000..ceeacda
--- /dev/null
+++ b/h5py/tests/types/test_conv.py
@@ -0,0 +1,14 @@
+
+import numpy as np
+import tempfile
+import h5py
+from h5py import tests
+
+class Base(tests.HTest):
+
+ def setUp(self):
+ self.f = h5py.File(tempfile.mktemp(), 'w', driver='core', backing_store=False)
+
+ def tearDown(self):
+ self.f.close()
+
diff --git a/h5py/tests/types/test_types.py b/h5py/tests/types/test_types.py
index 6ef3810..796508d 100644
--- a/h5py/tests/types/test_types.py
+++ b/h5py/tests/types/test_types.py
@@ -4,7 +4,7 @@
"""
import numpy as np
-from h5py import tests, h5t
+from h5py import tests, h5t, h5r
class TestIntegers(tests.HTest):
@@ -18,6 +18,18 @@ class TestIntegers(tests.HTest):
htype = h5t.py_create('i', logical=True)
self.assertIsInstance(htype, h5t.TypeIntegerID)
+ def test_enum_lit(self):
+ """ (Types) Enum literal is HDF5 integer """
+ dt = h5t.special_dtype(enum=('i', {'a': 1, 'b': 2}))
+ htype = h5t.py_create(dt)
+ self.assertIsInstance(htype, h5t.TypeIntegerID)
+
+ def test_enum_log(self):
+ """ (Types) Enum logical is HDF5 enum """
+ dt = h5t.special_dtype(enum=('i', {'a': 1, 'b': 2}))
+ htype = h5t.py_create(dt, logical=True)
+ self.assertIsInstance(htype, h5t.TypeEnumID)
+
class TestFloats(tests.HTest):
def test_float(self):
@@ -28,6 +40,7 @@ class TestFloats(tests.HTest):
def test_float_log(self):
""" (Types) Float dtype to HDF5 logical """
htype = h5t.py_create('f', logical=True)
+ self.assertIsInstance(htype, h5t.TypeFloatID)
class TestString(tests.HTest):
@@ -65,6 +78,78 @@ class TestString(tests.HTest):
self.assertEqual(htype.get_cset(), h5t.CSET_ASCII)
self.assertEqual(htype.get_strpad(), h5t.STR_NULLTERM)
+class TestArray(tests.HTest):
+
+ def test_array(self):
+ """ (Types) Multidimensional array type """
+ htype = h5t.py_create(('f',(2,2)))
+ self.assertIsInstance(htype, h5t.TypeArrayID)
+ self.assertEqual(htype.get_array_dims(), (2,2))
+
+ def test_array_dtype(self):
+ """ (Types) Array dtypes using non-tuple shapes """
+ dt1 = np.dtype('f4', (2,))
+ dt2 = np.dtype('f4', [2])
+ dt3 = np.dtype('f4', 2)
+ dt4 = np.dtype('f4', 2.1)
+ ht1 = h5t.py_create(dt1)
+ ht2 = h5t.py_create(dt2)
+ ht3 = h5t.py_create(dt3)
+ ht4 = h5t.py_create(dt4)
+ self.assertEqual(ht1.dtype, dt1)
+ self.assertEqual(ht2.dtype, dt1)
+ self.assertEqual(ht3.dtype, dt1)
+ self.assertEqual(ht4.dtype, dt1)
+
+class TestRef(tests.HTest):
+
+ def test_objref(self):
+ """ (Types) Object reference literal is Python object """
+ dt = h5t.special_dtype(ref=h5r.Reference)
+ htype = h5t.py_create(dt)
+ self.assertEqual(htype, h5t.PYTHON_OBJECT)
+
+ def test_objref_log(self):
+ """ (Types) Object reference logical is HDF5 reference """
+ dt = h5t.special_dtype(ref=h5r.Reference)
+ htype = h5t.py_create(dt, logical=True)
+ self.assertEqual(htype, h5t.STD_REF_OBJ)
+
+ def test_regref(self):
+ """ (Types) Region reference literal is Python object """
+ dt = h5t.special_dtype(ref=h5r.RegionReference)
+ htype = h5t.py_create(dt)
+ self.assertEqual(htype, h5t.PYTHON_OBJECT)
+
+ def test_regref_log(self):
+ """ (Types) Region reference logical is HDF5 dset reference """
+ dt = h5t.special_dtype(ref=h5r.RegionReference)
+ htype = h5t.py_create(dt, logical=True)
+ self.assertEqual(htype, h5t.STD_REF_DSETREG)
+
+class TestComplex(tests.HTest):
+
+ def test_complex(self):
+ """ (Types) Simple complex creation """
+ htype = h5t.py_create('c8')
+ self.assertIsInstance(htype, h5t.TypeCompoundID)
+
+class TestCompound(tests.HTest):
+
+ def test_simple(self):
+ """ (Types) Simple compound type (round-trip) """
+ dt = np.dtype([('a','i'), ('b','f'),('c','f8')])
+ htype = h5t.py_create(dt)
+ self.assertEqual(htype.dtype, dt)
+
+ def test_recursive(self):
+ """ (Types) Compound type containing compound type (round-trip) """
+ dt1 = np.dtype([('a','i'),('b','f')])
+ dt2 = np.dtype([('a',dt1),('b','f8')])
+ htype = h5t.py_create(dt2)
+ self.assertEqual(htype.dtype, dt2)
+
+
--
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