From a86ab305786048d58407ce79ebb7e7d19ef55dce Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Tue, 15 May 2018 16:37:20 -0700 Subject: [PATCH 1/3] fix iteritems --- pyqtgraph/debug.py | 2 +- pyqtgraph/exporters/Matplotlib.py | 2 +- pyqtgraph/graphicsItems/PlotDataItem.py | 2 +- pyqtgraph/multiprocess/parallelizer.py | 2 +- pyqtgraph/multiprocess/processes.py | 4 ++-- pyqtgraph/multiprocess/remoteproxy.py | 2 +- pyqtgraph/pgcollections.py | 4 ++-- pyqtgraph/util/lru_cache.py | 2 +- pyqtgraph/util/tests/test_lru_cache.py | 16 ++++++++-------- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pyqtgraph/debug.py b/pyqtgraph/debug.py index dd956620..3ddcae37 100644 --- a/pyqtgraph/debug.py +++ b/pyqtgraph/debug.py @@ -1097,7 +1097,7 @@ def pretty(data, indent=''): ind2 = indent + " " if isinstance(data, dict): ret = indent+"{\n" - for k, v in data.iteritems(): + for k, v in data.items(): ret += ind2 + repr(k) + ": " + pretty(v, ind2).strip() + "\n" ret += indent+"}\n" elif isinstance(data, list) or isinstance(data, tuple): diff --git a/pyqtgraph/exporters/Matplotlib.py b/pyqtgraph/exporters/Matplotlib.py index 8cec1cef..2da979b1 100644 --- a/pyqtgraph/exporters/Matplotlib.py +++ b/pyqtgraph/exporters/Matplotlib.py @@ -43,7 +43,7 @@ class MatplotlibExporter(Exporter): for ax in axl: if ax is None: continue - for loc, spine in ax.spines.iteritems(): + for loc, spine in ax.spines.items(): if loc in ['left', 'bottom']: pass elif loc in ['right', 'top']: diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index d7ea5100..c85c3e5b 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -771,7 +771,7 @@ def isSequence(obj): #if isinstance(arg, basestring): #return self.data[arg] #elif isinstance(arg, int): - #return dict([(k, v[arg]) for k, v in self.data.iteritems()]) + #return dict([(k, v[arg]) for k, v in self.data.items()]) #elif isinstance(arg, tuple): #arg = self._orderArgs(arg) #return self.data[arg[1]][arg[0]] diff --git a/pyqtgraph/multiprocess/parallelizer.py b/pyqtgraph/multiprocess/parallelizer.py index ef00be7c..989bd4f8 100644 --- a/pyqtgraph/multiprocess/parallelizer.py +++ b/pyqtgraph/multiprocess/parallelizer.py @@ -245,7 +245,7 @@ class Tasker(object): self.proc = process self.par = parallelizer self.tasks = tasks - for k, v in kwds.iteritems(): + for k, v in kwds.items(): setattr(self, k, v) def __iter__(self): diff --git a/pyqtgraph/multiprocess/processes.py b/pyqtgraph/multiprocess/processes.py index 0a372ef0..4cf2ab70 100644 --- a/pyqtgraph/multiprocess/processes.py +++ b/pyqtgraph/multiprocess/processes.py @@ -251,7 +251,7 @@ class ForkedProcess(RemoteEventHandler): proxyIDs = {} if preProxy is not None: - for k, v in preProxy.iteritems(): + for k, v in preProxy.items(): proxyId = LocalObjectProxy.registerObject(v) proxyIDs[k] = proxyId @@ -300,7 +300,7 @@ class ForkedProcess(RemoteEventHandler): RemoteEventHandler.__init__(self, remoteConn, name+'_child', pid=ppid) self.forkedProxies = {} - for name, proxyId in proxyIDs.iteritems(): + for name, proxyId in proxyIDs.items(): self.forkedProxies[name] = ObjectProxy(ppid, proxyId=proxyId, typeStr=repr(preProxy[name])) if target is not None: diff --git a/pyqtgraph/multiprocess/remoteproxy.py b/pyqtgraph/multiprocess/remoteproxy.py index bc02da83..f73d4309 100644 --- a/pyqtgraph/multiprocess/remoteproxy.py +++ b/pyqtgraph/multiprocess/remoteproxy.py @@ -545,7 +545,7 @@ class RemoteEventHandler(object): if autoProxy is True: args = [self.autoProxy(v, noProxyTypes) for v in args] - for k, v in kwds.iteritems(): + for k, v in kwds.items(): opts[k] = self.autoProxy(v, noProxyTypes) byteMsgs = [] diff --git a/pyqtgraph/pgcollections.py b/pyqtgraph/pgcollections.py index 76850622..db0fb74e 100644 --- a/pyqtgraph/pgcollections.py +++ b/pyqtgraph/pgcollections.py @@ -239,7 +239,7 @@ class CaselessDict(OrderedDict): return key.lower() in self.keyMap def update(self, d): - for k, v in d.iteritems(): + for k, v in d.items(): self[k] = v def copy(self): @@ -315,7 +315,7 @@ class ProtectedDict(dict): yield protect(v) def iteritems(self): - for k, v in self._data_.iteritems(): + for k, v in self._data_.items(): yield (k, protect(v)) def deepcopy(self): diff --git a/pyqtgraph/util/lru_cache.py b/pyqtgraph/util/lru_cache.py index 9c04abf3..69c1c20a 100644 --- a/pyqtgraph/util/lru_cache.py +++ b/pyqtgraph/util/lru_cache.py @@ -117,5 +117,5 @@ class LRUCache(object): for x in sorted(self._dict.itervalues(), key=operator.itemgetter(2)): yield x[0], x[1] else: - for x in self._dict.iteritems(): + for x in self._dict.items(): yield x[0], x[1] diff --git a/pyqtgraph/util/tests/test_lru_cache.py b/pyqtgraph/util/tests/test_lru_cache.py index c0cf9f8a..94451d97 100644 --- a/pyqtgraph/util/tests/test_lru_cache.py +++ b/pyqtgraph/util/tests/test_lru_cache.py @@ -22,28 +22,28 @@ def checkLru(lru): set([2, 1]) == set(lru.values()) #Iterates from the used in the last access to others based on access time. - assert [(2, 2), (1, 1)] == list(lru.iteritems(accessTime=True)) + assert [(2, 2), (1, 1)] == list(lru.items(accessTime=True)) lru[2] = 2 - assert [(1, 1), (2, 2)] == list(lru.iteritems(accessTime=True)) + assert [(1, 1), (2, 2)] == list(lru.items(accessTime=True)) del lru[2] - assert [(1, 1), ] == list(lru.iteritems(accessTime=True)) + assert [(1, 1), ] == list(lru.items(accessTime=True)) lru[2] = 2 - assert [(1, 1), (2, 2)] == list(lru.iteritems(accessTime=True)) + assert [(1, 1), (2, 2)] == list(lru.items(accessTime=True)) _a = lru[1] - assert [(2, 2), (1, 1)] == list(lru.iteritems(accessTime=True)) + assert [(2, 2), (1, 1)] == list(lru.items(accessTime=True)) _a = lru[2] - assert [(1, 1), (2, 2)] == list(lru.iteritems(accessTime=True)) + assert [(1, 1), (2, 2)] == list(lru.items(accessTime=True)) assert lru.get(2) == 2 assert lru.get(3) == None - assert [(1, 1), (2, 2)] == list(lru.iteritems(accessTime=True)) + assert [(1, 1), (2, 2)] == list(lru.items(accessTime=True)) lru.clear() - assert [] == list(lru.iteritems()) + assert [] == list(lru.items()) if __name__ == '__main__': From 1f380c93c167f36130763438aeb52adfccbe3547 Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Tue, 15 May 2018 16:37:58 -0700 Subject: [PATCH 2/3] fix itervalues --- pyqtgraph/flowchart/Node.py | 4 ++-- pyqtgraph/pgcollections.py | 2 +- pyqtgraph/util/lru_cache.py | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pyqtgraph/flowchart/Node.py b/pyqtgraph/flowchart/Node.py index c450a9f3..e7ce9360 100644 --- a/pyqtgraph/flowchart/Node.py +++ b/pyqtgraph/flowchart/Node.py @@ -222,7 +222,7 @@ class Node(QtCore.QObject): for t in self.inputs().values(): nodes |= set([i.node() for i in t.inputTerminals()]) return nodes - #return set([t.inputTerminals().node() for t in self.listInputs().itervalues()]) + #return set([t.inputTerminals().node() for t in self.listInputs().values()]) def __repr__(self): return "" % (self.name(), id(self)) @@ -477,7 +477,7 @@ class NodeGraphicsItem(GraphicsObject): #self.node.sigTerminalRenamed.connect(self.updateActionMenu) #def setZValue(self, z): - #for t, item in self.terminals.itervalues(): + #for t, item in self.terminals.values(): #item.setZValue(z+1) #GraphicsObject.setZValue(self, z) diff --git a/pyqtgraph/pgcollections.py b/pyqtgraph/pgcollections.py index db0fb74e..ac7f68fe 100644 --- a/pyqtgraph/pgcollections.py +++ b/pyqtgraph/pgcollections.py @@ -311,7 +311,7 @@ class ProtectedDict(dict): raise Exception("It is not safe to copy protected dicts! (instead try deepcopy, but be careful.)") def itervalues(self): - for v in self._data_.itervalues(): + for v in self._data_.values(): yield protect(v) def iteritems(self): diff --git a/pyqtgraph/util/lru_cache.py b/pyqtgraph/util/lru_cache.py index 69c1c20a..d0b160dd 100644 --- a/pyqtgraph/util/lru_cache.py +++ b/pyqtgraph/util/lru_cache.py @@ -94,14 +94,14 @@ class LRUCache(object): else: def values(self): - return [i[1] for i in self._dict.itervalues()] + return [i[1] for i in self._dict.values()] def keys(self): - return [x[0] for x in self._dict.itervalues()] + return [x[0] for x in self._dict.values()] def _resizeTo(self): - ordered = sorted(self._dict.itervalues(), key=operator.itemgetter(2))[:self.resizeTo] + ordered = sorted(self._dict.values(), key=operator.itemgetter(2))[:self.resizeTo] for i in ordered: del self._dict[i[0]] @@ -114,7 +114,7 @@ class LRUCache(object): ============= ====================================================== ''' if accessTime: - for x in sorted(self._dict.itervalues(), key=operator.itemgetter(2)): + for x in sorted(self._dict.values(), key=operator.itemgetter(2)): yield x[0], x[1] else: for x in self._dict.items(): From c390c5cd9802708cd444557f89c6c18cbaa357cd Mon Sep 17 00:00:00 2001 From: Luke Campagnola Date: Wed, 16 May 2018 08:33:51 -0700 Subject: [PATCH 3/3] fix lru_cache --- pyqtgraph/util/lru_cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyqtgraph/util/lru_cache.py b/pyqtgraph/util/lru_cache.py index d0b160dd..5300e0ff 100644 --- a/pyqtgraph/util/lru_cache.py +++ b/pyqtgraph/util/lru_cache.py @@ -80,7 +80,7 @@ class LRUCache(object): for i in ordered: del self._dict[i[0]] - def iteritems(self, accessTime=False): + def items(self, accessTime=False): ''' :param bool accessTime: If True sorts the returned items by the internal access time. @@ -105,7 +105,7 @@ class LRUCache(object): for i in ordered: del self._dict[i[0]] - def iteritems(self, accessTime=False): + def items(self, accessTime=False): ''' ============= ====================================================== **Arguments**