From 472140a3886689f986cfd803d4dd38fe72ec89ce Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Mon, 15 Aug 2022 18:34:39 +0200 Subject: datafile: update for python3 --- datafile.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/datafile.py b/datafile.py index 0a6d5c2..5b83bf0 100644 --- a/datafile.py +++ b/datafile.py @@ -203,7 +203,7 @@ class DataFile(object): self._f = h5py.File(path, mode) self.path = path try: - for it in self._f.itervalues(): + for it in self._f.values(): if self._first_iter is None and 'timestep' in it.attrs: self._first_iter = it.attrs['timestep'] if 'time' in it.attrs and it.attrs['time'] > 0.0: @@ -239,15 +239,16 @@ class DataFile(object): def _get_itertimes(self): rls = [] - datasets = map(lambda ds: (ds.attrs['level'], ds.attrs['timestep'], ds.attrs['time']), filter(lambda x: 'time' in x.attrs, self._f.itervalues())) + datasets = list(map(lambda ds: (ds.attrs['level'], ds.attrs['timestep'], ds.attrs['time']), + filter(lambda x: 'time' in x.attrs, self._f.values()))) i = 0 while True: - ds_rl = map(lambda ds: (ds[1], ds[2]), filter(lambda x: x[0] == i, datasets)) + ds_rl = list(map(lambda ds: (ds[1], ds[2]), filter(lambda x: x[0] == i, datasets))) if len(ds_rl) == 0: break - rls.append(sorted(ds_rl, cmp = lambda x, y: cmp(x[0], y[0]))) + rls.append(sorted(ds_rl, key = lambda x: x[0])) i += 1 return rls -- cgit v1.2.3