[h5py] 364/455: Add HL reference 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 fb7065b15a649ad22237c31bf3e81742b8b30e03
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Fri Jan 15 08:33:12 2010 +0000

    Add HL reference tests
---
 h5py/tests/high/test_refs.py | 95 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 95 insertions(+)

diff --git a/h5py/tests/high/test_refs.py b/h5py/tests/high/test_refs.py
new file mode 100644
index 0000000..d1e3931
--- /dev/null
+++ b/h5py/tests/high/test_refs.py
@@ -0,0 +1,95 @@
+
+
+from h5py import tests
+import h5py
+import numpy as np
+
+class Base(tests.HTest):
+
+    def setUp(self):
+        import tempfile
+        self.name = tempfile.mktemp()
+        self.f = h5py.File(self.name, 'w')
+
+    def tearDown(self):
+        import os
+        self.f.close()
+        os.unlink(self.name)
+
+
+class TestObjRef(Base):
+
+    def test_create(self):
+        """ (Refs) Group reference round-trip """
+        g = self.f.create_group('foo')
+        ref = g.ref
+        self.assertIsInstance(ref, h5py.Reference)
+        x = self.f[ref]
+        self.assertIsInstance(x, h5py.Group)
+        self.assertEqual(x, g)
+
+    @tests.fixme("Unimplemented in __getitem__")
+    def test_dtype(self):
+        """ (Refs) Named type reference round-trip """
+        dt = np.dtype('f')
+        self.f['nt'] = dt
+        nt = self.f['nt']
+        ref = nt.ref
+        self.assertIsInstance(ref, h5py.Reference)
+        x = self.f[ref]
+        self.assertIsInstance(x, h5py.Datatype)
+        self.assertEqual(x, nt)
+
+    @tests.require(api=18)
+    def test_name(self):
+        """ (Refs) .name property works on dereferenced objects (1.8) """
+        g = self.f.create_group('foo')
+        x = self.f[g.ref]
+        self.assertEqual(x.name, g.name)
+
+    @tests.require(api=16)
+    def test_name_16(self):
+        """ (Refs) .name property gives None for dereferenced objects (1.6) """
+        g = self.f.create_group('foo')
+        x = self.f[g.ref]
+        self.assertIsNone(x.name)
+
+    @tests.fixme("TypeError in h5r")
+    def test_bool(self):
+        """ (Refs) __nonzero__ tracks validity """
+        ref = h5py.Reference()
+        self.assert_(not ref)
+        self.assert_(self.f.ref)
+
+    @tests.fixme("TypeError in h5r")
+    def test_exc(self):
+        """ (Refs) Deref of empty ref raises ValueError """
+        ref = h5py.Reference()
+        self.assertRaises(ValueError, self.f.__getitem__, ref)
+
+class TestRegRef(Base):
+
+    def setUp(self):
+        Base.setUp(self)
+        self.ds = self.f.create_dataset('ds', (100,100), 'f')
+        self.arr = np.arange(100*100, dtype='f').reshape((100,100))
+        self.ds[...] = self.arr
+
+    def test_create(self):
+        """ (Refs) Region reference round-trip with Group """
+        ref = self.ds.regionref[...]
+        self.assertIsInstance(ref, h5py.RegionReference)
+        x = self.f[ref]
+        self.assertIsInstance(x, h5py.Dataset)
+        self.assertEqual(x, self.ds)
+
+    def test_sel(self):
+        """ (Refs) Region selection can be used as slice (2D -> 1D) """
+        ref = self.ds.regionref[10:20, 17:35]
+        x = self.ds[ref]
+        self.assertArrayEqual(x, self.arr[10:20, 17:35].flatten())
+
+
+
+
+

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