diff options
author | Stefan van der Walt <stefan@sun.ac.za> | 2009-07-04 12:44:11 +0000 |
---|---|---|
committer | Stefan van der Walt <stefan@sun.ac.za> | 2009-07-04 12:44:11 +0000 |
commit | b9b934cdd9e51c51b377d1682169928e62976376 (patch) | |
tree | 5b83d810da217cadc3d283eee2fab2408f5edd2d /numpy/lib/io.py | |
parent | ae6da8374a055b5dfe738c03c41ff8e001f51180 (diff) | |
download | numpy-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.py | 21 |
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. |