summaryrefslogtreecommitdiff
path: root/numpy/lib/io.py
diff options
context:
space:
mode:
authorStefan van der Walt <stefan@sun.ac.za>2009-07-04 12:44:11 +0000
committerStefan van der Walt <stefan@sun.ac.za>2009-07-04 12:44:11 +0000
commitb9b934cdd9e51c51b377d1682169928e62976376 (patch)
tree5b83d810da217cadc3d283eee2fab2408f5edd2d /numpy/lib/io.py
parentae6da8374a055b5dfe738c03c41ff8e001f51180 (diff)
downloadnumpy-b9b934cdd9e51c51b377d1682169928e62976376.tar.gz
More complete dictionary interface to NpzFile [patch by David Warde-Farley]
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r--numpy/lib/io.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py
index 3464b568c..9199a0de2 100644
--- a/numpy/lib/io.py
+++ b/numpy/lib/io.py
@@ -118,6 +118,27 @@ class NpzFile(object):
else:
raise KeyError, "%s is not a file in the archive" % key
+
+ def __iter__(self):
+ return iter(self.files)
+
+ def items(self):
+ return [(f, self[f]) for f in self.files]
+
+ def iteritems(self):
+ for f in self.files:
+ yield (f, self[f])
+
+ def keys(self):
+ return self.files
+
+ def iterkeys(self):
+ return self.__iter__()
+
+ def __contains__(self, key):
+ return self.files.__contains__(key)
+
+
def load(file, mmap_mode=None):
"""
Load a pickled, ``.npy``, or ``.npz`` binary file.