From 183fdd53e924595977e15abcabb1f8325e3be72f Mon Sep 17 00:00:00 2001
From: "Boeckenhoff, Daniel (dboe)" <daniel.boeckenhoff@ipp.mpg.de>
Date: Tue, 18 Sep 2018 14:15:46 +0200
Subject: [PATCH] keys() to list(dict)

---
 tfields/bounding_box.py |  2 +-
 tfields/core.py         | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/tfields/bounding_box.py b/tfields/bounding_box.py
index 3b47e1e..b9e3d3b 100644
--- a/tfields/bounding_box.py
+++ b/tfields/bounding_box.py
@@ -173,7 +173,7 @@ class Node(object):
             return self
         if len(self.cut_expr) > 1:
             raise ValueError("cut_expr is too long")
-        key = self.cut_expr.keys()[0]
+        key = list(self.cut_expr)[0]
         value = locals()[key]
         if value <= self.cut_expr[key]:
             return self.left.find_leaf(point, _in_recursion=True)
diff --git a/tfields/core.py b/tfields/core.py
index 1541b7d..f6689d8 100644
--- a/tfields/core.py
+++ b/tfields/core.py
@@ -329,7 +329,7 @@ class AbstractNdarray(np.ndarray):
         '''
         De-Flatten the first layer of lists
         '''
-        for key in sorted(d.keys()):
+        for key in sorted(list(d)):
             if '::' in key:
                 splits = key.split('::')
                 attr, _, end = key.partition('::')
@@ -349,10 +349,10 @@ class AbstractNdarray(np.ndarray):
         '''
         Build the lists (recursively)
         '''
-        for key in list_dict.keys():
+        for key in list(list_dict):
             sub_dict = list_dict[key]
             list_dict[key] = []
-            for index in sorted(sub_dict.keys()):
+            for index in sorted(list(sub_dict)):
                 bulk_type = sub_dict[index].get('bulk_type').tolist()
                 if isinstance(bulk_type, bytes):
                     # asthonishingly, this is not necessary under linux. Found under nt. ???
@@ -690,7 +690,7 @@ class Tensors(AbstractNdarray):
             >>> assert np.array_equal(lins3[:, 1], [4, 9])
 
         """
-        cls_kwargs = {attr: kwargs.pop(attr) for attr in list(kwargs.keys()) if attr in cls.__slots__}
+        cls_kwargs = {attr: kwargs.pop(attr) for attr in list(kwargs) if attr in cls.__slots__}
         inst = cls.__new__(cls,
                            tfields.lib.grid.igrid(*base_vectors, **kwargs),
                            **cls_kwargs)
@@ -1563,7 +1563,7 @@ class TensorMaps(TensorFields):
                     item.maps = [mp.copy() for mp in item.maps]
                     indices = np.array(range(len(self)))
                     keep_indices = indices[index]
-                    if isinstance(keep_indices, (int, np.int64)):
+                    if isinstance(keep_indices, (int, np.int64, np.int32)):
                         keep_indices = [keep_indices]
                     delete_indices = set(indices).difference(set(keep_indices))
 
-- 
GitLab