[h5py] 271/455: Test updates for beta

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:41 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 4b869b255e9ee4e2e11254295631901d3da2ba6f
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Thu Jun 4 03:07:59 2009 +0000

    Test updates for beta
---
 h5py/h5e.pyx                 |  2 +-
 h5py/tests/test_highlevel.py |  2 +-
 h5py/tests/test_vlen.py      | 88 +++++++++++++++++++++++++++++++++++---------
 3 files changed, 73 insertions(+), 19 deletions(-)

diff --git a/h5py/h5e.pyx b/h5py/h5e.pyx
index a9afd2f..bef7a8d 100644
--- a/h5py/h5e.pyx
+++ b/h5py/h5e.pyx
@@ -333,7 +333,7 @@ cdef herr_t walk_cb(int n, H5E_error_t *err_desc, void* stack_in):
     element = ErrorStackElement()
 
     element.e = err_desc[0]
-    stack += [element]
+    stack.append(element)
 
     return 0
 
diff --git a/h5py/tests/test_highlevel.py b/h5py/tests/test_highlevel.py
index f6c5faf..e7e5c89 100644
--- a/h5py/tests/test_highlevel.py
+++ b/h5py/tests/test_highlevel.py
@@ -56,7 +56,7 @@ class TestFile(HDF5TestCase):
         os.unlink(self.fname)
 
     def test_unicode(self):
-        # Three cases:
+        # Two cases:
         # 1. Unicode
         #       Store w/filesystem encoding; should be readable as Unicode
         # 2. Raw byte string in ASCII range
diff --git a/h5py/tests/test_vlen.py b/h5py/tests/test_vlen.py
index 584a45f..027e964 100644
--- a/h5py/tests/test_vlen.py
+++ b/h5py/tests/test_vlen.py
@@ -5,6 +5,7 @@ import unittest
 import os.path as op
 import os
 from common import skip
+from tempfile import mktemp
 
 class TestVlen(unittest.TestCase):
 
@@ -24,15 +25,23 @@ class TestVlen(unittest.TestCase):
 
     def test_write_attr(self):
 
-        f = h5py.File('tmp.hdf5','w')
-        value = "This is the string!"
+        fname = mktemp('.hdf5')
+
+        f = h5py.File(fname,'w')
+        try:
+            value = "This is the string!"
+            
+            dt = h5py.new_vlen(str)
+            f.attrs.create('test_string', value, dtype=dt)
+            self.assertEqual(f.attrs['test_string'], value)
         
-        dt = h5py.new_vlen(str)
-        f.attrs.create('test_string', value, dtype=dt)
-        self.assertEqual(f.attrs['test_string'], value)
-    
-        aid = h5py.h5a.open(f.id, 'test_string')
-        self.assertEqual(dt, aid.dtype)
+            aid = h5py.h5a.open(f.id, 'test_string')
+            self.assertEqual(dt, aid.dtype)
+        finally:
+            if f:
+                f.close()
+                os.unlink(fname)            
+
 
     def test_read_strings(self):
 
@@ -58,22 +67,26 @@ class TestVlen(unittest.TestCase):
     
     def test_write_strings(self):
 
-        f = h5py.File('tmp.hdf5', 'w')
-        dt = h5py.new_vlen(str)
+        fname = mktemp('.hdf5')
 
-        data_arr = np.array(["Hello there!", "string 2", "", "!!!!!"], dtype=dt)
+        f = h5py.File(fname, 'w')
+        try:
+            dt = h5py.new_vlen(str)
 
-        slices = [np.s_[0], np.s_[1:3], np.s_[...]]
+            data_arr = np.array(["Hello there!", "string 2", "", "!!!!!"], dtype=dt)
+
+            slices = [np.s_[0], np.s_[1:3], np.s_[...]]
 
-        try:
             dset = f.create_dataset("vlen_ds", (4,), dt)
             for s in slices:
                 print "slc %s data %s" % (s, data_arr[s])
                 dset[s] = data_arr[s]
                 self.assert_(np.all(dset[s] == data_arr[s]))
         finally:
-            f.close()
-            #os.unlink('tmp.hdf5')
+            if f:
+                f.close()
+                os.unlink(fname)            
+
 
     def test_compound(self):
 
@@ -81,7 +94,8 @@ class TestVlen(unittest.TestCase):
         dts = [ [('a_name','>i4'), ('vlen',vlen_dt), ('d_name', '>f4')],
                 [('a_name','=i8'), ('vlen',vlen_dt), ('d_name', '>f4')] ]
 
-        f = h5py.File('tmp.hdf5', 'w')
+        fname = mktemp('.hdf5')
+        f = h5py.File(fname, 'w')
         try:
             for dt in dts:
                 if 'vlen_ds' in f:                 del f['vlen_ds']
@@ -93,7 +107,47 @@ class TestVlen(unittest.TestCase):
                 self.assert_(np.all(dset[...] == data))
 
         finally:
-            f.close()
+            if f:
+                f.close()
+                os.unlink(fname)
+
+    def test_array(self):
+
+        fname = mktemp('.hdf5')
+        f = h5py.File(fname, 'w')
+
+        data = [["Hi", ""],["Hello there", "A string"]]
+
+        try:
+            vlen_dt = h5py.new_vlen(str)
+            arr_dt = np.dtype((vlen_dt, (2,2)))
+
+            arr = np.ndarray((20,), dtype=arr_dt)
+
+            arr[0,:] = data
+
+            ds = f.create_dataset('ds', data=arr)
+
+            self.assert_(np.all(ds[0] == arr[0]))
+        finally:
+            if f:
+                f.close()
+                os.unlink(fname)            
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 
 

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