summaryrefslogtreecommitdiff
path: root/numpy/lib/tests/test_io.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2009-07-04 12:44:54 +0000
committerStefan van der Walt <stefan@sun.ac.za>2009-07-04 12:44:54 +0000
commita3a99e2f84e36ef876094494464e6bcecb7ee0ab (patch)
treecb0ca48a49a8d1a649f0efebae1ac310e10d2ecc /numpy/lib/tests/test_io.py
parentb9b934cdd9e51c51b377d1682169928e62976376 (diff)
downloadnumpy-a3a99e2f84e36ef876094494464e6bcecb7ee0ab.tar.gz
Add tests for dictionary interface to NpzFile.
Diffstat (limited to 'numpy/lib/tests/test_io.py')
-rw-r--r--numpy/lib/tests/test_io.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/numpy/lib/tests/test_io.py b/numpy/lib/tests/test_io.py
index e5a73a86a..185ceef7c 100644
--- a/numpy/lib/tests/test_io.py
+++ b/numpy/lib/tests/test_io.py
@@ -916,5 +916,31 @@ def test_gzip_loadtxt_from_string():
f = gzip.GzipFile(fileobj=s, mode="r")
assert_array_equal(np.loadtxt(f), [1, 2, 3])
+def test_npzfile_dict():
+ s = StringIO.StringIO()
+ x = np.zeros((3, 3))
+ y = np.zeros((3, 3))
+
+ np.savez(s, x=x, y=y)
+ s.seek(0)
+
+ z = np.load(s)
+
+ assert 'x' in z
+ assert 'y' in z
+ assert 'x' in z.keys()
+ assert 'y' in z.keys()
+
+ for f, a in z.iteritems():
+ assert f in ['x', 'y']
+ assert_equal(a.shape, (3, 3))
+
+ assert len(z.items()) == 2
+
+ for f in z:
+ assert f in ['x', 'y']
+
+ assert 'x' in list(z.iterkeys())
+
if __name__ == "__main__":
run_module_suite()