[h5py] 365/455: Add H5S tests
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:51 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 fd5dff07bce81ef5d3f6aec6a6510b16478e051b
Author: andrewcollette <andrew.collette at gmail.com>
Date: Sat Jan 16 23:50:49 2010 +0000
Add H5S tests
---
h5py/tests/low/test_h5s.py | 93 ++++++++++++++++++++++++++++++++++++++++++++++
h5py/tests/test_h5s.py | 20 ----------
2 files changed, 93 insertions(+), 20 deletions(-)
diff --git a/h5py/tests/low/test_h5s.py b/h5py/tests/low/test_h5s.py
new file mode 100644
index 0000000..ade782d
--- /dev/null
+++ b/h5py/tests/low/test_h5s.py
@@ -0,0 +1,93 @@
+
+from h5py import tests
+from h5py import *
+
+class TestCreate(tests.HTest):
+
+ def test_scalar(self):
+ """ (H5S) Create scalar dataspace """
+ sid = h5s.create(h5s.SCALAR)
+ self.assertEqual(sid.get_simple_extent_type(), h5s.SCALAR)
+
+ def test_simple(self):
+ """ (H5S) Create simple dataspaces """
+ sid = h5s.create(h5s.SIMPLE)
+ self.assertEqual(sid.get_simple_extent_type(), h5s.SIMPLE)
+
+ def test_simple_scalar(self):
+ """ (H5S) Create from empty tuple results in scalar space """
+ sid = h5s.create_simple(())
+ self.assertEqual(sid.get_simple_extent_type(), h5s.SCALAR)
+
+ def test_simple_init(self):
+ """ (H5S) Create simple dataspace given extent """
+ sid = h5s.create_simple((10,10))
+ self.assertEqual(sid.shape, (10,10))
+ self.assertEqual(sid.get_simple_extent_dims(maxdims=True), (10,10))
+
+ def test_simple_limit(self):
+ """ (H5S) Create simple dataspace given extent and limit """
+ sid = h5s.create_simple((10,10), (15,15))
+ self.assertEqual(sid.shape, (10,10))
+ self.assertEqual(sid.get_simple_extent_dims(maxdims=True), (15,15))
+
+ def test_simple_ulimit(self):
+ """ (H5S) Create simple dataspace with unlimited dimension """
+ sid = h5s.create_simple((10,10), (h5s.UNLIMITED,15))
+ self.assertEqual(sid.shape, (10,10))
+ self.assertEqual(sid.get_simple_extent_dims(maxdims=True), (h5s.UNLIMITED,15))
+
+ def test_simple_exc(self):
+ """ (H5S) Extent/limit mismatch raises ValueError """
+ self.assertRaises(ValueError, h5s.create_simple, (10,10), (10,9))
+
+ def test_simple_exc1(self):
+ """ (H5S) Extent/limit rank mismatch raises ValueError """
+ self.assertRaises(ValueError, h5s.create_simple, (10,10), (20,))
+
+class TestEncodeDecode(tests.HTest):
+
+ def setUp(self):
+ self.sid = h5s.create_simple((10,10))
+ self.sid.select_hyperslab((2,2),(5,5))
+
+ def tearDown(self):
+ del self.sid
+
+ def assertEqualSpaces(self, sid1, sid2):
+ self.assertIsInstance(sid1, h5s.SpaceID)
+ self.assertIsInstance(sid2, h5s.SpaceID)
+ self.assertEqual(sid1.shape, sid2.shape)
+ self.assertEqual(sid1.get_select_bounds(), sid2.get_select_bounds())
+
+ @tests.require(api=18)
+ def test_ed(self):
+ """ (H5S) Encode/decode round trip """
+ enc = self.sid.encode()
+ self.assertIsInstance(enc, str)
+ dec = h5s.decode(enc)
+ self.assertEqualSpaces(self.sid, dec)
+
+ @tests.require(api=18)
+ def test_pickle(self):
+ """ (H5S) Encode/decode round trip via pickling """
+ import pickle
+ pkl = pickle.dumps(self.sid)
+ dec = pickle.loads(pkl)
+ self.assertEqualSpaces(self.sid, dec)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/h5py/tests/test_h5s.py b/h5py/tests/test_h5s.py
index 184bf34..84f56dd 100644
--- a/h5py/tests/test_h5s.py
+++ b/h5py/tests/test_h5s.py
@@ -31,26 +31,6 @@ class TestH5S(unittest.TestCase):
sid2 = sid.copy()
self.assertEqual(h5i.get_type(sid2), h5i.DATASPACE)
- def test_simple(self):
- # Tests create_simple, get_simple_extent_dims, get_simple_extent_ndims
-
- for space, max_space in zip(spaces, max_spaces):
- sid = h5s.create_simple(space,max_space)
- self.assertEqual(sid.get_simple_extent_dims(), space)
- self.assertEqual(sid.get_simple_extent_dims(maxdims=True), max_space)
- self.assertEqual(sid.get_simple_extent_ndims(), len(space))
-
- self.assertRaises(ValueError, h5s.create_simple, None)
- self.assertRaises(ValueError, h5s.create_simple, (10,10), (10,9))
- self.assertRaises(ValueError, h5s.create_simple, (10,10), (10,))
-
- def test_is_simple(self):
- # According to HDF5 docs, all dataspaces are "simple," even scalar ones.
- sid = h5s.create(h5s.SCALAR)
- self.assert_(sid.is_simple())
- sid = h5s.create(h5s.SIMPLE)
- self.assert_(sid.is_simple())
-
def test_offset_simple(self):
sid = h5s.create_simple((100,100))
--
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