diff --git a/tfields/bounding_box.py b/tfields/bounding_box.py index 3b47e1eff3f98dcb8a61c034e022c8cba144858c..b9e3d3bf50baaaef2acbe1d520578e5f0b5f0e63 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 1541b7d00c2f8d3b140810f77ba7336efb4b970f..f6689d810c83ffdce0793b728d72a7500a83a732 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))