diff --git a/pyqtgraph/GraphicsScene/GraphicsScene.py b/pyqtgraph/GraphicsScene/GraphicsScene.py index e4dd1c16..c1f0bf34 100644 --- a/pyqtgraph/GraphicsScene/GraphicsScene.py +++ b/pyqtgraph/GraphicsScene/GraphicsScene.py @@ -5,7 +5,6 @@ from time import perf_counter, perf_counter_ns from ..Qt import QtCore, QtGui, QT_LIB, isQObjectAlive from ..Point import Point -from .. import functions as fn from .mouseEvents import * from .. import debug as debug from .. import getConfigOption diff --git a/pyqtgraph/GraphicsScene/mouseEvents.py b/pyqtgraph/GraphicsScene/mouseEvents.py index 77e5afed..2195aba3 100644 --- a/pyqtgraph/GraphicsScene/mouseEvents.py +++ b/pyqtgraph/GraphicsScene/mouseEvents.py @@ -1,6 +1,7 @@ +# -*- coding: utf-8 -*- from time import perf_counter from ..Point import Point -from ..Qt import QtCore, QtGui +from ..Qt import QtCore import weakref class MouseDragEvent(object): @@ -377,4 +378,4 @@ class HoverEvent(object): return self.__dragItems - \ No newline at end of file + diff --git a/pyqtgraph/ThreadsafeTimer.py b/pyqtgraph/ThreadsafeTimer.py index 2dc4b9bd..2292d016 100644 --- a/pyqtgraph/ThreadsafeTimer.py +++ b/pyqtgraph/ThreadsafeTimer.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from .Qt import QtCore, QtGui +from .Qt import QtCore __all__ = ['ThreadsafeTimer'] diff --git a/pyqtgraph/Transform3D.py b/pyqtgraph/Transform3D.py index b5a41bc2..9f957bc3 100644 --- a/pyqtgraph/Transform3D.py +++ b/pyqtgraph/Transform3D.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from .Qt import QtCore, QtGui +from .Qt import QtGui from . import functions as fn from .Vector import Vector import numpy as np diff --git a/pyqtgraph/WidgetGroup.py b/pyqtgraph/WidgetGroup.py index 6b99f86c..c993882e 100644 --- a/pyqtgraph/WidgetGroup.py +++ b/pyqtgraph/WidgetGroup.py @@ -8,7 +8,7 @@ This class addresses the problem of having to save and restore the state of a large group of widgets. """ -from .Qt import QtCore, QtGui, QT_LIB +from .Qt import QtCore, QtGui import weakref, inspect from .python2_3 import asUnicode @@ -280,4 +280,4 @@ class WidgetGroup(QtCore.QObject): #print "%s: Cached value %s != set value %s" % (name, str(self.cache[name]), str(v1)) - \ No newline at end of file + diff --git a/pyqtgraph/canvas/Canvas.py b/pyqtgraph/canvas/Canvas.py index 3c04c03b..59793b6f 100644 --- a/pyqtgraph/canvas/Canvas.py +++ b/pyqtgraph/canvas/Canvas.py @@ -9,8 +9,6 @@ import importlib ui_template = importlib.import_module( f'.CanvasTemplate_{QT_LIB.lower()}', package=__package__) -import numpy as np -from .. import debug import weakref import gc from .CanvasManager import CanvasManager diff --git a/pyqtgraph/console/Console.py b/pyqtgraph/console/Console.py index 8e66282d..c8b045f2 100644 --- a/pyqtgraph/console/Console.py +++ b/pyqtgraph/console/Console.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import sys, re, os, time, traceback, subprocess +import sys, re, traceback, subprocess import pickle from ..Qt import QtCore, QtGui, QT_LIB diff --git a/pyqtgraph/dockarea/DockArea.py b/pyqtgraph/dockarea/DockArea.py index ee9a5f53..86538f75 100644 --- a/pyqtgraph/dockarea/DockArea.py +++ b/pyqtgraph/dockarea/DockArea.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- import weakref -from ..Qt import QtCore, QtGui +from ..Qt import QtGui from .Container import * from .DockDrop import * from .Dock import Dock -from .. import debug as debug from ..python2_3 import basestring diff --git a/pyqtgraph/exporters/CSVExporter.py b/pyqtgraph/exporters/CSVExporter.py index aec27a16..26825466 100644 --- a/pyqtgraph/exporters/CSVExporter.py +++ b/pyqtgraph/exporters/CSVExporter.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from ..Qt import QtGui, QtCore +from ..Qt import QtCore from .Exporter import Exporter from ..parametertree import Parameter from .. import PlotItem diff --git a/pyqtgraph/exporters/Exporter.py b/pyqtgraph/exporters/Exporter.py index 0634c049..ca3cd606 100644 --- a/pyqtgraph/exporters/Exporter.py +++ b/pyqtgraph/exporters/Exporter.py @@ -1,5 +1,6 @@ +# -*- coding: utf-8 -*- from ..widgets.FileDialog import FileDialog -from ..Qt import QtGui, QtCore, QtSvg +from ..Qt import QtGui, QtCore from ..python2_3 import asUnicode, basestring from ..GraphicsScene import GraphicsScene import os, re diff --git a/pyqtgraph/exporters/HDF5Exporter.py b/pyqtgraph/exporters/HDF5Exporter.py index 83499a86..6fbeeb23 100644 --- a/pyqtgraph/exporters/HDF5Exporter.py +++ b/pyqtgraph/exporters/HDF5Exporter.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtCore from .Exporter import Exporter from ..parametertree import Parameter from .. import PlotItem diff --git a/pyqtgraph/exporters/PrintExporter.py b/pyqtgraph/exporters/PrintExporter.py index 79511842..69c23165 100644 --- a/pyqtgraph/exporters/PrintExporter.py +++ b/pyqtgraph/exporters/PrintExporter.py @@ -1,7 +1,7 @@ +# -*- coding: utf-8 -*- from .Exporter import Exporter from ..parametertree import Parameter -from ..Qt import QtGui, QtCore, QtSvg -import re +from ..Qt import QtGui, QtCore translate = QtCore.QCoreApplication.translate diff --git a/pyqtgraph/exporters/SVGExporter.py b/pyqtgraph/exporters/SVGExporter.py index 36995cc3..3dc12b2c 100644 --- a/pyqtgraph/exporters/SVGExporter.py +++ b/pyqtgraph/exporters/SVGExporter.py @@ -1,7 +1,8 @@ +# -*- coding: utf-8 -*- from .Exporter import Exporter from ..python2_3 import asUnicode from ..parametertree import Parameter -from ..Qt import QtGui, QtCore, QtSvg, QT_LIB +from ..Qt import QtGui, QtCore, QtSvg from .. import debug from .. import functions as fn import re diff --git a/pyqtgraph/flowchart/FlowchartGraphicsView.py b/pyqtgraph/flowchart/FlowchartGraphicsView.py index a5a43fd5..cef262c5 100644 --- a/pyqtgraph/flowchart/FlowchartGraphicsView.py +++ b/pyqtgraph/flowchart/FlowchartGraphicsView.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from ..Qt import QtGui, QtCore from ..widgets.GraphicsView import GraphicsView -from ..GraphicsScene import GraphicsScene from ..graphicsItems.ViewBox import ViewBox translate = QtCore.QCoreApplication.translate diff --git a/pyqtgraph/flowchart/Node.py b/pyqtgraph/flowchart/Node.py index 37c6df09..f45d7529 100644 --- a/pyqtgraph/flowchart/Node.py +++ b/pyqtgraph/flowchart/Node.py @@ -5,7 +5,6 @@ from .. import functions as fn from .Terminal import * from collections import OrderedDict from ..debug import * -import numpy as np import warnings translate = QtCore.QCoreApplication.translate diff --git a/pyqtgraph/flowchart/library/Data.py b/pyqtgraph/flowchart/library/Data.py index 6397fffa..696b8ea1 100644 --- a/pyqtgraph/flowchart/library/Data.py +++ b/pyqtgraph/flowchart/library/Data.py @@ -4,8 +4,6 @@ from ...Qt import QtGui, QtCore, QtWidgets import numpy as np import sys from .common import * -from ...SRTTransform import SRTTransform -from ...Point import Point from ...widgets.TreeWidget import TreeWidget from ...graphicsItems.LinearRegionItem import LinearRegionItem @@ -481,4 +479,3 @@ class AsType(CtrlNode): def processData(self, data): s = self.stateGroup.state() return data.astype(s['dtype']) - diff --git a/pyqtgraph/flowchart/library/Display.py b/pyqtgraph/flowchart/library/Display.py index 642e6491..4ea85878 100644 --- a/pyqtgraph/flowchart/library/Display.py +++ b/pyqtgraph/flowchart/library/Display.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- from ..Node import Node -import weakref from ...Qt import QtCore, QtGui from ...graphicsItems.ScatterPlotItem import ScatterPlotItem -from ...graphicsItems.PlotCurveItem import PlotCurveItem from ... import PlotDataItem, ComboBox from .common import * diff --git a/pyqtgraph/flowchart/library/Filters.py b/pyqtgraph/flowchart/library/Filters.py index 9a7fa401..1bd4dec2 100644 --- a/pyqtgraph/flowchart/library/Filters.py +++ b/pyqtgraph/flowchart/library/Filters.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- import numpy as np -from ...Qt import QtCore, QtGui -from ..Node import Node from . import functions from ... import functions as pgfn from .common import * diff --git a/pyqtgraph/flowchart/library/functions.py b/pyqtgraph/flowchart/library/functions.py index cb7fb41a..a50aeaca 100644 --- a/pyqtgraph/flowchart/library/functions.py +++ b/pyqtgraph/flowchart/library/functions.py @@ -1,6 +1,7 @@ +# -*- coding: utf-8 -*- import numpy as np from ...metaarray import MetaArray -from ...python2_3 import basestring, xrange +from ...python2_3 import xrange def downsample(data, n, axis=0, xvals='subsample'): @@ -354,4 +355,4 @@ def removePeriodic(data, f0=60.0, dt=None, harmonics=10, samples=4): return data2 - \ No newline at end of file + diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index 9b123b08..a5ba110c 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -7,7 +7,6 @@ Distributed under MIT/X11 license. See license.txt for more information. from __future__ import division -import ctypes import decimal import re import struct @@ -2403,11 +2402,6 @@ def traceImage(image, values, smooth=0.5): If image is RGB or RGBA, then the shape of values should be (nvals, 3/4) The parameter *smooth* is expressed in pixels. """ - try: - import scipy.ndimage as ndi - except ImportError: - raise Exception("traceImage() requires the package scipy.ndimage, but it is not importable.") - if values.ndim == 2: values = values.T values = values[np.newaxis, np.newaxis, ...].astype(float) diff --git a/pyqtgraph/graphicsItems/ArrowItem.py b/pyqtgraph/graphicsItems/ArrowItem.py index 842a3787..c57acfd1 100644 --- a/pyqtgraph/graphicsItems/ArrowItem.py +++ b/pyqtgraph/graphicsItems/ArrowItem.py @@ -1,7 +1,7 @@ +# -*- coding: utf-8 -*- from math import hypot -from ..Qt import QtGui, QtCore +from ..Qt import QtGui from .. import functions as fn -import numpy as np __all__ = ['ArrowItem'] class ArrowItem(QtGui.QGraphicsPathItem): diff --git a/pyqtgraph/graphicsItems/CurvePoint.py b/pyqtgraph/graphicsItems/CurvePoint.py index 171a05e5..afa1f466 100644 --- a/pyqtgraph/graphicsItems/CurvePoint.py +++ b/pyqtgraph/graphicsItems/CurvePoint.py @@ -1,8 +1,8 @@ +# -*- coding: utf-8 -*- from math import atan2, degrees from ..Qt import QtGui, QtCore from . import ArrowItem from ..functions import clip_scalar -from ..Point import Point import weakref from .GraphicsObject import GraphicsObject diff --git a/pyqtgraph/graphicsItems/ErrorBarItem.py b/pyqtgraph/graphicsItems/ErrorBarItem.py index 433a231b..e52f045c 100644 --- a/pyqtgraph/graphicsItems/ErrorBarItem.py +++ b/pyqtgraph/graphicsItems/ErrorBarItem.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- -from ..Qt import QtGui, QtCore +from ..Qt import QtGui from .GraphicsObject import GraphicsObject from .. import getConfigOption from .. import functions as fn -import numpy as np __all__ = ['ErrorBarItem'] diff --git a/pyqtgraph/graphicsItems/GradientEditorItem.py b/pyqtgraph/graphicsItems/GradientEditorItem.py index 5d134ad8..1bddd35f 100644 --- a/pyqtgraph/graphicsItems/GradientEditorItem.py +++ b/pyqtgraph/graphicsItems/GradientEditorItem.py @@ -4,7 +4,6 @@ import weakref import numpy as np from ..Qt import QtGui, QtCore from .. import functions as fn -from .GraphicsObject import GraphicsObject from .GraphicsWidget import GraphicsWidget from ..widgets.SpinBox import SpinBox from collections import OrderedDict diff --git a/pyqtgraph/graphicsItems/GraphicsLayout.py b/pyqtgraph/graphicsItems/GraphicsLayout.py index 7aa3842e..8b451043 100644 --- a/pyqtgraph/graphicsItems/GraphicsLayout.py +++ b/pyqtgraph/graphicsItems/GraphicsLayout.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtGui from .. import functions as fn from .GraphicsWidget import GraphicsWidget ## Must be imported at the end to avoid cyclic-dependency hell: diff --git a/pyqtgraph/graphicsItems/GraphicsObject.py b/pyqtgraph/graphicsItems/GraphicsObject.py index 403714ba..a1b8cb4b 100644 --- a/pyqtgraph/graphicsItems/GraphicsObject.py +++ b/pyqtgraph/graphicsItems/GraphicsObject.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore, QT_LIB +# -*- coding: utf-8 -*- +from ..Qt import QtGui, QT_LIB if QT_LIB.startswith('PyQt'): from ..Qt import sip from .GraphicsItem import GraphicsItem diff --git a/pyqtgraph/graphicsItems/GraphicsWidget.py b/pyqtgraph/graphicsItems/GraphicsWidget.py index c379ce8e..e7d7cd02 100644 --- a/pyqtgraph/graphicsItems/GraphicsWidget.py +++ b/pyqtgraph/graphicsItems/GraphicsWidget.py @@ -1,5 +1,5 @@ -from ..Qt import QtGui, QtCore -from ..GraphicsScene import GraphicsScene +# -*- coding: utf-8 -*- +from ..Qt import QtGui from .GraphicsItem import GraphicsItem __all__ = ['GraphicsWidget'] @@ -55,5 +55,3 @@ class GraphicsWidget(GraphicsItem, QtGui.QGraphicsWidget): p.addRect(self.boundingRect()) #print "shape:", p.boundingRect() return p - - diff --git a/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py b/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py index 78eed4f2..e6a189d4 100644 --- a/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py +++ b/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py @@ -1,4 +1,4 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- from ..Point import Point __all__ = ['GraphicsWidgetAnchor'] @@ -108,4 +108,4 @@ class GraphicsWidgetAnchor(object): pos = p + (o-a) + off self.setPos(pos) - \ No newline at end of file + diff --git a/pyqtgraph/graphicsItems/InfiniteLine.py b/pyqtgraph/graphicsItems/InfiniteLine.py index a50d91f7..8c26b413 100644 --- a/pyqtgraph/graphicsItems/InfiniteLine.py +++ b/pyqtgraph/graphicsItems/InfiniteLine.py @@ -8,7 +8,6 @@ from .TextItem import TextItem from .ViewBox import ViewBox from .. import functions as fn import numpy as np -import weakref __all__ = ['InfiniteLine', 'InfLineLabel'] diff --git a/pyqtgraph/graphicsItems/ItemGroup.py b/pyqtgraph/graphicsItems/ItemGroup.py index 2826c720..79976d8c 100644 --- a/pyqtgraph/graphicsItems/ItemGroup.py +++ b/pyqtgraph/graphicsItems/ItemGroup.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtCore from .GraphicsObject import GraphicsObject __all__ = ['ItemGroup'] @@ -19,4 +20,3 @@ class ItemGroup(GraphicsObject): def addItem(self, item): item.setParentItem(self) - diff --git a/pyqtgraph/graphicsItems/PColorMeshItem.py b/pyqtgraph/graphicsItems/PColorMeshItem.py index 04a03270..28db681b 100644 --- a/pyqtgraph/graphicsItems/PColorMeshItem.py +++ b/pyqtgraph/graphicsItems/PColorMeshItem.py @@ -1,20 +1,14 @@ +# -*- coding: utf-8 -*- from __future__ import division from ..Qt import QtGui, QtCore import numpy as np from .. import functions as fn -from .. import debug as debug from .GraphicsObject import GraphicsObject -from ..Point import Point from .. import getConfigOption from .GradientEditorItem import Gradients # List of colormaps from ..colormap import ColorMap -try: - from collections.abc import Callable -except ImportError: - # fallback for python < 3.3 - from collections import Callable __all__ = ['PColorMeshItem'] diff --git a/pyqtgraph/graphicsItems/PlotCurveItem.py b/pyqtgraph/graphicsItems/PlotCurveItem.py index 3e59197f..9aca7d76 100644 --- a/pyqtgraph/graphicsItems/PlotCurveItem.py +++ b/pyqtgraph/graphicsItems/PlotCurveItem.py @@ -6,8 +6,7 @@ import warnings import numpy as np from .GraphicsObject import GraphicsObject from .. import functions as fn -from ..Point import Point -import struct, sys +import sys from .. import getConfigOption from .. import debug diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index c6413319..97c8cb55 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -2,7 +2,6 @@ import warnings import math import numpy as np -from .. import metaarray as metaarray from ..Qt import QtCore from .GraphicsObject import GraphicsObject from .PlotCurveItem import PlotCurveItem diff --git a/pyqtgraph/graphicsItems/ROI.py b/pyqtgraph/graphicsItems/ROI.py index 86528d5f..b3048efc 100644 --- a/pyqtgraph/graphicsItems/ROI.py +++ b/pyqtgraph/graphicsItems/ROI.py @@ -21,7 +21,6 @@ from math import atan2, cos, degrees, sin, hypot from .. import functions as fn from .GraphicsObject import GraphicsObject from .UIGraphicsItem import UIGraphicsItem -from .. import getConfigOption import warnings import sys diff --git a/pyqtgraph/graphicsItems/ScaleBar.py b/pyqtgraph/graphicsItems/ScaleBar.py index 475b342b..685fe7e2 100644 --- a/pyqtgraph/graphicsItems/ScaleBar.py +++ b/pyqtgraph/graphicsItems/ScaleBar.py @@ -1,8 +1,8 @@ +# -*- coding: utf-8 -*- from ..Qt import QtGui, QtCore from .GraphicsObject import * from .GraphicsWidgetAnchor import * from .TextItem import TextItem -import numpy as np from .. import functions as fn from .. import getConfigOption from ..Point import Point @@ -67,5 +67,3 @@ class ScaleBar(GraphicsObject, GraphicsWidgetAnchor): anchor = (anchorx, anchory) self.anchor(itemPos=anchor, parentPos=anchor, offset=offset) return ret - - diff --git a/pyqtgraph/graphicsItems/ScatterPlotItem.py b/pyqtgraph/graphicsItems/ScatterPlotItem.py index c2c8498e..62974509 100644 --- a/pyqtgraph/graphicsItems/ScatterPlotItem.py +++ b/pyqtgraph/graphicsItems/ScatterPlotItem.py @@ -8,7 +8,6 @@ from .. import Qt from ..Qt import QtGui, QtCore, QT_LIB from ..Point import Point from .. import functions as fn -from .GraphicsItem import GraphicsItem from .GraphicsObject import GraphicsObject from .. import getConfigOption from collections import OrderedDict diff --git a/pyqtgraph/graphicsItems/UIGraphicsItem.py b/pyqtgraph/graphicsItems/UIGraphicsItem.py index 13c66e91..9108e4a1 100644 --- a/pyqtgraph/graphicsItems/UIGraphicsItem.py +++ b/pyqtgraph/graphicsItems/UIGraphicsItem.py @@ -1,5 +1,5 @@ +# -*- coding: utf-8 -*- from ..Qt import QtGui, QtCore, QT_LIB -import weakref from .GraphicsObject import GraphicsObject if QT_LIB.startswith('PyQt'): from ..Qt import sip diff --git a/pyqtgraph/graphicsItems/VTickGroup.py b/pyqtgraph/graphicsItems/VTickGroup.py index 2b4f256f..1a3c8c77 100644 --- a/pyqtgraph/graphicsItems/VTickGroup.py +++ b/pyqtgraph/graphicsItems/VTickGroup.py @@ -1,11 +1,11 @@ +# -*- coding: utf-8 -*- if __name__ == '__main__': import os, sys path = os.path.abspath(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(path, '..', '..')) -from ..Qt import QtGui, QtCore +from ..Qt import QtGui from .. import functions as fn -import weakref from .UIGraphicsItem import UIGraphicsItem __all__ = ['VTickGroup'] @@ -96,4 +96,4 @@ class VTickGroup(UIGraphicsItem): p.setPen(self.pen) p.drawPath(self.path) - \ No newline at end of file + diff --git a/pyqtgraph/graphicsWindows.py b/pyqtgraph/graphicsWindows.py index dd42880b..1e11181b 100644 --- a/pyqtgraph/graphicsWindows.py +++ b/pyqtgraph/graphicsWindows.py @@ -12,7 +12,6 @@ from .Qt import QtCore, QtGui, mkQApp from .widgets.PlotWidget import * from .imageview import * from .widgets.GraphicsLayoutWidget import GraphicsLayoutWidget -from .widgets.GraphicsView import GraphicsView import warnings diff --git a/pyqtgraph/metaarray/MetaArray.py b/pyqtgraph/metaarray/MetaArray.py index 919347c2..7d852ec7 100644 --- a/pyqtgraph/metaarray/MetaArray.py +++ b/pyqtgraph/metaarray/MetaArray.py @@ -10,7 +10,7 @@ new methods for slicing and indexing the array based on this meta data. More info at http://www.scipy.org/Cookbook/MetaArray """ -import types, copy, threading, os, re +import copy, os import pickle import numpy as np from ..python2_3 import basestring diff --git a/pyqtgraph/multiprocess/processes.py b/pyqtgraph/multiprocess/processes.py index cc9dbb8c..bab43f9e 100644 --- a/pyqtgraph/multiprocess/processes.py +++ b/pyqtgraph/multiprocess/processes.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import subprocess, atexit, os, sys, time, random, socket, signal, inspect +import subprocess, atexit, os, sys, time, signal, inspect import multiprocessing.connection try: import cPickle as pickle @@ -388,7 +388,7 @@ class RemoteQtEventHandler(RemoteEventHandler): RemoteEventHandler.__init__(self, *args, **kwds) def startEventTimer(self): - from ..Qt import QtGui, QtCore + from ..Qt import QtCore self.timer = QtCore.QTimer() self.timer.timeout.connect(self.processRequests) self.timer.start(10) @@ -397,7 +397,7 @@ class RemoteQtEventHandler(RemoteEventHandler): try: RemoteEventHandler.processRequests(self) except ClosedError: - from ..Qt import QtGui, QtCore + from ..Qt import QtGui QtGui.QApplication.instance().quit() self.timer.stop() #raise SystemExit @@ -466,7 +466,7 @@ def startQtEventLoop(name, port, authkey, ppid, debug=False): conn = multiprocessing.connection.Client(('localhost', int(port)), authkey=authkey) if debug: cprint.cout(debug, '[%d] connected; starting remote proxy.\n' % os.getpid(), -1) - from ..Qt import QtGui, QtCore + from ..Qt import QtGui app = QtGui.QApplication.instance() #print app if app is None: diff --git a/pyqtgraph/opengl/MeshData.py b/pyqtgraph/opengl/MeshData.py index 3f7a77b4..8aac31f8 100644 --- a/pyqtgraph/opengl/MeshData.py +++ b/pyqtgraph/opengl/MeshData.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import numpy as np from ..Qt import QtGui -from .. import functions as fn from ..python2_3 import xrange diff --git a/pyqtgraph/opengl/items/GLImageItem.py b/pyqtgraph/opengl/items/GLImageItem.py index dabe1c41..d099196e 100644 --- a/pyqtgraph/opengl/items/GLImageItem.py +++ b/pyqtgraph/opengl/items/GLImageItem.py @@ -1,7 +1,6 @@ +# -*- coding: utf-8 -*- from OpenGL.GL import * from .. GLGraphicsItem import GLGraphicsItem -from ...Qt import QtGui -import numpy as np __all__ = ['GLImageItem'] diff --git a/pyqtgraph/opengl/items/GLLinePlotItem.py b/pyqtgraph/opengl/items/GLLinePlotItem.py index dcc98cc0..ad593ef1 100644 --- a/pyqtgraph/opengl/items/GLLinePlotItem.py +++ b/pyqtgraph/opengl/items/GLLinePlotItem.py @@ -1,7 +1,6 @@ +# -*- coding: utf-8 -*- from OpenGL.GL import * -from OpenGL.arrays import vbo from .. GLGraphicsItem import GLGraphicsItem -from .. import shaders from ... import QtGui from ... import functions as fn import numpy as np @@ -51,7 +50,6 @@ class GLLinePlotItem(GLGraphicsItem): for arg in args: if arg in kwds: setattr(self, arg, kwds[arg]) - #self.vbo.pop(arg, None) self.update() def paint(self): diff --git a/pyqtgraph/opengl/items/GLScatterPlotItem.py b/pyqtgraph/opengl/items/GLScatterPlotItem.py index 834ede0b..3aa42aa7 100644 --- a/pyqtgraph/opengl/items/GLScatterPlotItem.py +++ b/pyqtgraph/opengl/items/GLScatterPlotItem.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- from OpenGL.GL import * -from OpenGL.arrays import vbo from .. GLGraphicsItem import GLGraphicsItem from .. import shaders from ... import functions as fn @@ -20,7 +19,6 @@ class GLScatterPlotItem(GLGraphicsItem): self.size = 10 self.color = [1.0,1.0,1.0,0.5] self.pxMode = True - #self.vbo = {} ## VBO does not appear to improve performance very much. self.setData(**kwds) self.shader = None @@ -51,7 +49,6 @@ class GLScatterPlotItem(GLGraphicsItem): for arg in args: if arg in kwds: setattr(self, arg, kwds[arg]) - #self.vbo.pop(arg, None) self.pxMode = kwds.get('pxMode', self.pxMode) self.update() @@ -79,11 +76,6 @@ class GLScatterPlotItem(GLGraphicsItem): self.shader = shaders.getShaderProgram('pointSprite') - #def getVBO(self, name): - #if name not in self.vbo: - #self.vbo[name] = vbo.VBO(getattr(self, name).astype('f')) - #return self.vbo[name] - #def setupGLState(self): #"""Prepare OpenGL state for drawing. This function is called immediately before painting.""" ##glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ## requires z-sorting to render properly. diff --git a/pyqtgraph/opengl/items/GLSurfacePlotItem.py b/pyqtgraph/opengl/items/GLSurfacePlotItem.py index e39ef3bb..3057fa4a 100644 --- a/pyqtgraph/opengl/items/GLSurfacePlotItem.py +++ b/pyqtgraph/opengl/items/GLSurfacePlotItem.py @@ -1,7 +1,7 @@ +# -*- coding: utf-8 -*- from OpenGL.GL import * from .GLMeshItem import GLMeshItem from .. MeshData import MeshData -from ...Qt import QtGui import numpy as np diff --git a/pyqtgraph/opengl/items/GLVolumeItem.py b/pyqtgraph/opengl/items/GLVolumeItem.py index cbe22db9..04c212bf 100644 --- a/pyqtgraph/opengl/items/GLVolumeItem.py +++ b/pyqtgraph/opengl/items/GLVolumeItem.py @@ -1,8 +1,8 @@ +# -*- coding: utf-8 -*- from OpenGL.GL import * from .. GLGraphicsItem import GLGraphicsItem from ...Qt import QtGui import numpy as np -from ... import debug __all__ = ['GLVolumeItem'] @@ -227,4 +227,3 @@ class GLVolumeItem(GLGraphicsItem): #glPopMatrix() - diff --git a/pyqtgraph/parametertree/Parameter.py b/pyqtgraph/parametertree/Parameter.py index 4605bf2a..b123d192 100644 --- a/pyqtgraph/parametertree/Parameter.py +++ b/pyqtgraph/parametertree/Parameter.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from .. import functions as fn -from ..Qt import QtGui, QtCore -import os, weakref, re +from ..Qt import QtCore +import weakref, re from collections import OrderedDict from ..python2_3 import asUnicode, basestring from .ParameterItem import ParameterItem diff --git a/pyqtgraph/parametertree/ParameterItem.py b/pyqtgraph/parametertree/ParameterItem.py index 4b6b3e0a..1b4924b2 100644 --- a/pyqtgraph/parametertree/ParameterItem.py +++ b/pyqtgraph/parametertree/ParameterItem.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- from ..Qt import QtGui, QtCore from ..python2_3 import asUnicode -import os, weakref, re translate = QtCore.QCoreApplication.translate diff --git a/pyqtgraph/parametertree/ParameterSystem.py b/pyqtgraph/parametertree/ParameterSystem.py index 33bb2de8..df5b5640 100644 --- a/pyqtgraph/parametertree/ParameterSystem.py +++ b/pyqtgraph/parametertree/ParameterSystem.py @@ -1,3 +1,6 @@ +# -*- coding: utf-8 -*- +__all__ = ["ParameterSystem", "SystemSolver"] + from .parameterTypes import GroupParameter from .. import functions as fn from .SystemSolver import SystemSolver @@ -124,4 +127,3 @@ class ParameterSystem(GroupParameter): - diff --git a/pyqtgraph/parametertree/ParameterTree.py b/pyqtgraph/parametertree/ParameterTree.py index d546578a..db549d90 100644 --- a/pyqtgraph/parametertree/ParameterTree.py +++ b/pyqtgraph/parametertree/ParameterTree.py @@ -1,10 +1,8 @@ +# -*- coding: utf-8 -*- from ..Qt import QtCore, QtWidgets from ..widgets.TreeWidget import TreeWidget -import os, weakref, re from .ParameterItem import ParameterItem -#import functions as fn - - + class ParameterTree(TreeWidget): """Widget used to display or control data from a hierarchy of Parameters""" diff --git a/pyqtgraph/pgcollections.py b/pyqtgraph/pgcollections.py index faadc063..3c3ec86b 100644 --- a/pyqtgraph/pgcollections.py +++ b/pyqtgraph/pgcollections.py @@ -17,7 +17,6 @@ warnings.warn( ) import threading -import sys import copy from collections import OrderedDict diff --git a/pyqtgraph/reload.py b/pyqtgraph/reload.py index 655a83a6..ef93bc8d 100644 --- a/pyqtgraph/reload.py +++ b/pyqtgraph/reload.py @@ -312,289 +312,3 @@ def getPreviousVersion(obj): else: # python 3 return types.MethodType(oldfunc, self) - - - -## Tests: -# write modules to disk, import, then re-write and run again -if __name__ == '__main__': - doQtTest = True - try: - from PyQt4 import QtCore - if not hasattr(QtCore, 'Signal'): - QtCore.Signal = QtCore.pyqtSignal - #app = QtGui.QApplication([]) - class Btn(QtCore.QObject): - sig = QtCore.Signal() - def emit(self): - self.sig.emit() - btn = Btn() - except: - raise - - import os - if not os.path.isdir('test1'): - os.mkdir('test1') - with open('test1/__init__.py', 'w'): - pass - modFile1 = "test1/test1.py" - modCode1 = """ -import sys -class A(object): - def __init__(self, msg): - object.__init__(self) - self.msg = msg - def fn(self, pfx = ""): - print(pfx+"A class: %%s %%s" %% (str(self.__class__), str(id(self.__class__)))) - print(pfx+" %%s: %d" %% self.msg) - -class B(A): - def fn(self, pfx=""): - print(pfx+"B class:", self.__class__, id(self.__class__)) - print(pfx+" %%s: %d" %% self.msg) - print(pfx+" calling superclass.. (%%s)" %% id(A) ) - A.fn(self, " ") -""" - - modFile2 = "test2.py" - modCode2 = """ -from test1.test1 import A -from test1.test1 import B - -a1 = A("ax1") -b1 = B("bx1") -class C(A): - def __init__(self, msg): - #print "| C init:" - #print "| C.__bases__ = ", map(id, C.__bases__) - #print "| A:", id(A) - #print "| A.__init__ = ", id(A.__init__.im_func), id(A.__init__.im_func.__code__), id(A.__init__.im_class) - A.__init__(self, msg + "(init from C)") - -def fn(): - print("fn: %s") -""" - - with open(modFile1, 'w') as f: - f.write(modCode1 % (1, 1)) - with open(modFile2, 'w') as f: - f.write(modCode2 % ("message 1", )) - import test1.test1 as test1 - import test2 - print("Test 1 originals:") - A1 = test1.A - B1 = test1.B - a1 = test1.A("a1") - b1 = test1.B("b1") - a1.fn() - b1.fn() - #print "function IDs a1 bound method: %d a1 func: %d a1 class: %d b1 func: %d b1 class: %d" % (id(a1.fn), id(a1.fn.im_func), id(a1.fn.im_class), id(b1.fn.im_func), id(b1.fn.im_class)) - - - from test2 import fn, C - - if doQtTest: - print("Button test before:") - btn.sig.connect(fn) - btn.sig.connect(a1.fn) - btn.emit() - #btn.sig.emit() - print("") - - #print "a1.fn referrers:", sys.getrefcount(a1.fn.im_func), gc.get_referrers(a1.fn.im_func) - - - print("Test2 before reload:") - - fn() - oldfn = fn - test2.a1.fn() - test2.b1.fn() - c1 = test2.C('c1') - c1.fn() - - os.remove(modFile1+'c') - with open(modFile1, 'w') as f: - f.write(modCode1 %(2, 2)) - print("\n----RELOAD test1-----\n") - reloadAll(os.path.abspath(__file__)[:10], debug=True) - - - print("Subclass test:") - c2 = test2.C('c2') - c2.fn() - - - os.remove(modFile2+'c') - with open(modFile2, 'w') as f: - f.write(modCode2 % ("message 2", )) - print("\n----RELOAD test2-----\n") - reloadAll(os.path.abspath(__file__)[:10], debug=True) - - if doQtTest: - print("Button test after:") - btn.emit() - #btn.sig.emit() - - #print "a1.fn referrers:", sys.getrefcount(a1.fn.im_func), gc.get_referrers(a1.fn.im_func) - - print("Test2 after reload:") - fn() - test2.a1.fn() - test2.b1.fn() - - print("\n==> Test 1 Old instances:") - a1.fn() - b1.fn() - c1.fn() - #print "function IDs a1 bound method: %d a1 func: %d a1 class: %d b1 func: %d b1 class: %d" % (id(a1.fn), id(a1.fn.im_func), id(a1.fn.im_class), id(b1.fn.im_func), id(b1.fn.im_class)) - - print("\n==> Test 1 New instances:") - a2 = test1.A("a2") - b2 = test1.B("b2") - a2.fn() - b2.fn() - c2 = test2.C('c2') - c2.fn() - #print "function IDs a1 bound method: %d a1 func: %d a1 class: %d b1 func: %d b1 class: %d" % (id(a1.fn), id(a1.fn.im_func), id(a1.fn.im_class), id(b1.fn.im_func), id(b1.fn.im_class)) - - - - - os.remove(modFile1+'c') - os.remove(modFile2+'c') - with open(modFile1, 'w') as f: - f.write(modCode1 % (3, 3)) - with open(modFile2, 'w') as f: - f.write(modCode2 % ("message 3", )) - - print("\n----RELOAD-----\n") - reloadAll(os.path.abspath(__file__)[:10], debug=True) - - if doQtTest: - print("Button test after:") - btn.emit() - #btn.sig.emit() - - #print "a1.fn referrers:", sys.getrefcount(a1.fn.im_func), gc.get_referrers(a1.fn.im_func) - - print("Test2 after reload:") - fn() - test2.a1.fn() - test2.b1.fn() - - print("\n==> Test 1 Old instances:") - a1.fn() - b1.fn() - print("function IDs a1 bound method: %d a1 func: %d a1 class: %d b1 func: %d b1 class: %d" % (id(a1.fn), id(a1.fn.__func__), id(a1.fn.__self__.__class__), id(b1.fn.__func__), id(b1.fn.__self__.__class__))) - - print("\n==> Test 1 New instances:") - a2 = test1.A("a2") - b2 = test1.B("b2") - a2.fn() - b2.fn() - print("function IDs a1 bound method: %d a1 func: %d a1 class: %d b1 func: %d b1 class: %d" % (id(a1.fn), id(a1.fn.__func__), id(a1.fn.__self__.__class__), id(b1.fn.__func__), id(b1.fn.__self__.__class__))) - - - os.remove(modFile1) - os.remove(modFile2) - os.remove(modFile1+'c') - os.remove(modFile2+'c') - os.system('rm -r test1') - - - - - - - - -# -# Failure graveyard ahead: -# - - -"""Reload Importer: -Hooks into import system to -1) keep a record of module dependencies as they are imported -2) make sure modules are always reloaded in correct order -3) update old classes and functions to use reloaded code""" - -#import imp, sys - -## python's import hook mechanism doesn't work since we need to be -## informed every time there is an import statement, not just for new imports -#class ReloadImporter: - #def __init__(self): - #self.depth = 0 - - #def find_module(self, name, path): - #print " "*self.depth + "find: ", name, path - ##if name == 'PyQt4' and path is None: - ##print "PyQt4 -> PySide" - ##self.modData = imp.find_module('PySide') - ##return self - ##return None ## return none to allow the import to proceed normally; return self to intercept with load_module - #self.modData = imp.find_module(name, path) - #self.depth += 1 - ##sys.path_importer_cache = {} - #return self - - #def load_module(self, name): - #mod = imp.load_module(name, *self.modData) - #self.depth -= 1 - #print " "*self.depth + "load: ", name - #return mod - -#def pathHook(path): - #print "path hook:", path - #raise ImportError -#sys.path_hooks.append(pathHook) - -#sys.meta_path.append(ReloadImporter()) - - -### replace __import__ with a wrapper that tracks module dependencies -#modDeps = {} -#reloadModule = None -#origImport = __builtins__.__import__ -#def _import(name, globals=None, locals=None, fromlist=None, level=-1, stack=[]): - ### Note that stack behaves as a static variable. - ##print " "*len(importStack) + "import %s" % args[0] - #stack.append(set()) - #mod = origImport(name, globals, locals, fromlist, level) - #deps = stack.pop() - #if len(stack) > 0: - #stack[-1].add(mod) - #elif reloadModule is not None: ## If this is the top level import AND we're inside a module reload - #modDeps[reloadModule].add(mod) - - #if mod in modDeps: - #modDeps[mod] |= deps - #else: - #modDeps[mod] = deps - - - #return mod - -#__builtins__.__import__ = _import - -### replace -#origReload = __builtins__.reload -#def _reload(mod): - #reloadModule = mod - #ret = origReload(mod) - #reloadModule = None - #return ret -#__builtins__.reload = _reload - - -#def reload(mod, visited=None): - #if visited is None: - #visited = set() - #if mod in visited: - #return - #visited.add(mod) - #for dep in modDeps.get(mod, []): - #reload(dep, visited) - #__builtins__.reload(mod) diff --git a/pyqtgraph/util/cprint.py b/pyqtgraph/util/cprint.py index 8b4fa208..533ae4b0 100644 --- a/pyqtgraph/util/cprint.py +++ b/pyqtgraph/util/cprint.py @@ -1,9 +1,10 @@ +# -*- coding: utf-8 -*- """ Cross-platform color text printing Based on colorama (see pyqtgraph/util/colorama/README.txt) """ -import sys, re +import sys from .colorama.winterm import WinTerm, WinColor, WinStyle from .colorama.win32 import windll @@ -98,5 +99,3 @@ def cout(*args): def cerr(*args): """Shorthand for cprint('stderr', ...)""" cprint('stderr', *args) - - diff --git a/pyqtgraph/util/numba_helper.py b/pyqtgraph/util/numba_helper.py index 6eb46680..74bafbfa 100644 --- a/pyqtgraph/util/numba_helper.py +++ b/pyqtgraph/util/numba_helper.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- from warnings import warn from .. import getConfigOption @@ -5,7 +6,7 @@ from .. import getConfigOption def getNumbaFunctions(): if getConfigOption("useNumba"): try: - import numba + import numba # noqa except ImportError: warn("numba library could not be loaded, but 'useNumba' is set.") return None diff --git a/pyqtgraph/widgets/ColorMapWidget.py b/pyqtgraph/widgets/ColorMapWidget.py index ee153423..5690e53c 100644 --- a/pyqtgraph/widgets/ColorMapWidget.py +++ b/pyqtgraph/widgets/ColorMapWidget.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtCore from .. import parametertree as ptree import numpy as np from collections import OrderedDict @@ -270,5 +271,3 @@ class EnumColorMapItem(ptree.types.GroupParameter): #colors[mask] = nanColor return colors - - diff --git a/pyqtgraph/widgets/ComboBox.py b/pyqtgraph/widgets/ComboBox.py index 67c3c889..a690404e 100644 --- a/pyqtgraph/widgets/ComboBox.py +++ b/pyqtgraph/widgets/ComboBox.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- import sys -from ..Qt import QtGui, QtCore -from ..SignalProxy import SignalProxy +from ..Qt import QtGui from collections import OrderedDict from ..python2_3 import asUnicode, basestring diff --git a/pyqtgraph/widgets/DataFilterWidget.py b/pyqtgraph/widgets/DataFilterWidget.py index 55af95ca..a6f4d09f 100644 --- a/pyqtgraph/widgets/DataFilterWidget.py +++ b/pyqtgraph/widgets/DataFilterWidget.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtCore from .. import parametertree as ptree import numpy as np from collections import OrderedDict diff --git a/pyqtgraph/widgets/DataTreeWidget.py b/pyqtgraph/widgets/DataTreeWidget.py index b6987553..4c6f33a3 100644 --- a/pyqtgraph/widgets/DataTreeWidget.py +++ b/pyqtgraph/widgets/DataTreeWidget.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from ..Qt import QtGui, QtCore +from ..Qt import QtGui from collections import OrderedDict from .TableWidget import TableWidget from ..python2_3 import asUnicode @@ -7,7 +7,7 @@ import types, traceback import numpy as np try: - import metaarray + import metaarray # noqa HAVE_METAARRAY = True except: HAVE_METAARRAY = False diff --git a/pyqtgraph/widgets/DiffTreeWidget.py b/pyqtgraph/widgets/DiffTreeWidget.py index 53f575e6..89a6a4f2 100644 --- a/pyqtgraph/widgets/DiffTreeWidget.py +++ b/pyqtgraph/widgets/DiffTreeWidget.py @@ -1,9 +1,7 @@ # -*- coding: utf-8 -*- -from ..Qt import QtGui, QtCore -from collections import OrderedDict +from ..Qt import QtGui from .DataTreeWidget import DataTreeWidget from .. import functions as fn -import types, traceback import numpy as np __all__ = ['DiffTreeWidget'] @@ -161,4 +159,4 @@ class DiffTreeWidget(QtGui.QWidget): assert info == expect except Exception: raise NotImplementedError("Cannot compare objects of type %s" % type(info)) - \ No newline at end of file + diff --git a/pyqtgraph/widgets/FileDialog.py b/pyqtgraph/widgets/FileDialog.py index 853d675a..8b93cb46 100644 --- a/pyqtgraph/widgets/FileDialog.py +++ b/pyqtgraph/widgets/FileDialog.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtGui import sys __all__ = ['FileDialog'] @@ -11,4 +12,4 @@ class FileDialog(QtGui.QFileDialog): QtGui.QFileDialog.__init__(self, *args) if sys.platform == 'darwin': - self.setOption(QtGui.QFileDialog.Option.DontUseNativeDialog) \ No newline at end of file + self.setOption(QtGui.QFileDialog.Option.DontUseNativeDialog) diff --git a/pyqtgraph/widgets/GradientWidget.py b/pyqtgraph/widgets/GradientWidget.py index 809b4f66..2700590c 100644 --- a/pyqtgraph/widgets/GradientWidget.py +++ b/pyqtgraph/widgets/GradientWidget.py @@ -2,8 +2,6 @@ from ..Qt import QtGui, QtCore, QtWidgets from .GraphicsView import GraphicsView from ..graphicsItems.GradientEditorItem import GradientEditorItem -import weakref -import numpy as np __all__ = ['GradientWidget'] @@ -75,5 +73,3 @@ class GradientWidget(GraphicsView): def widgetGroupInterface(self): return (self.sigGradientChanged, self.saveState, self.restoreState) - - diff --git a/pyqtgraph/widgets/GraphicsLayoutWidget.py b/pyqtgraph/widgets/GraphicsLayoutWidget.py index 6249ba26..4e724a3e 100644 --- a/pyqtgraph/widgets/GraphicsLayoutWidget.py +++ b/pyqtgraph/widgets/GraphicsLayoutWidget.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -from ..Qt import QtGui, mkQApp +from ..Qt import mkQApp from ..graphicsItems.GraphicsLayout import GraphicsLayout from .GraphicsView import GraphicsView diff --git a/pyqtgraph/widgets/GraphicsView.py b/pyqtgraph/widgets/GraphicsView.py index ed73cca5..9fd0570c 100644 --- a/pyqtgraph/widgets/GraphicsView.py +++ b/pyqtgraph/widgets/GraphicsView.py @@ -9,7 +9,6 @@ from ..Qt import QtCore, QtGui, QtWidgets, QT_LIB from ..Point import Point from ..GraphicsScene import GraphicsScene from .. import functions as fn -from .. import debug as debug from .. import getConfigOption __all__ = ['GraphicsView'] diff --git a/pyqtgraph/widgets/LayoutWidget.py b/pyqtgraph/widgets/LayoutWidget.py index 6eb1c8b9..df9b01e7 100644 --- a/pyqtgraph/widgets/LayoutWidget.py +++ b/pyqtgraph/widgets/LayoutWidget.py @@ -1,4 +1,5 @@ -from ..Qt import QtGui, QtCore +# -*- coding: utf-8 -*- +from ..Qt import QtGui __all__ = ['LayoutWidget'] class LayoutWidget(QtGui.QWidget): @@ -97,5 +98,3 @@ class LayoutWidget(QtGui.QWidget): #items = [] #for i in list(self.items.keys()): #self.removeItem(i) - - diff --git a/pyqtgraph/widgets/MatplotlibWidget.py b/pyqtgraph/widgets/MatplotlibWidget.py index 2c305397..3b639ed7 100644 --- a/pyqtgraph/widgets/MatplotlibWidget.py +++ b/pyqtgraph/widgets/MatplotlibWidget.py @@ -1,5 +1,5 @@ -from ..Qt import QtGui, QtCore, QT_LIB -import matplotlib +# -*- coding: utf-8 -*- +from ..Qt import QtGui from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar diff --git a/pyqtgraph/widgets/RemoteGraphicsView.py b/pyqtgraph/widgets/RemoteGraphicsView.py index 3e34a757..1affefea 100644 --- a/pyqtgraph/widgets/RemoteGraphicsView.py +++ b/pyqtgraph/widgets/RemoteGraphicsView.py @@ -1,10 +1,10 @@ +# -*- coding: utf-8 -*- from ..Qt import QtGui, QtCore, QT_LIB if QT_LIB.startswith('PyQt'): from ..Qt import sip from .. import multiprocess as mp from .GraphicsView import GraphicsView from .. import CONFIG_OPTIONS -import numpy as np import mmap, tempfile, os, atexit, sys, random __all__ = ['RemoteGraphicsView'] @@ -292,4 +292,3 @@ class Renderer(GraphicsView): typ = QtCore.QEvent.Type(typ) ev = QtCore.QEvent(typ) return super().leaveEvent(ev) - diff --git a/pyqtgraph/widgets/SpinBox.py b/pyqtgraph/widgets/SpinBox.py index 7a9af656..bd7b8e49 100644 --- a/pyqtgraph/widgets/SpinBox.py +++ b/pyqtgraph/widgets/SpinBox.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- from math import isnan, isinf -from decimal import Decimal as D ## Use decimal to avoid accumulating floating-point errors import decimal -import weakref import re from ..Qt import QtGui, QtCore @@ -74,7 +72,7 @@ class SpinBox(QtGui.QAbstractSpinBox): 'wrapping': False, ## normal arithmetic step - 'step': D('0.01'), ## if 'dec' is false, the spinBox steps by 'step' every time + 'step': decimal.Decimal('0.01'), ## if 'dec' is false, the spinBox steps by 'step' every time ## if 'dec' is True, the step size is relative to the value ## 'step' needs to be an integral divisor of ten, ie 'step'*n=10 for some integer value of n (but only if dec is True) 'dec': False, ## if true, does decimal stepping. ie from 1-10 it steps by 'step', from 10 to 100 it steps by 10*'step', etc. @@ -94,14 +92,14 @@ class SpinBox(QtGui.QAbstractSpinBox): 'format': asUnicode("{scaledValue:.{decimals}g}{suffixGap}{siPrefix}{suffix}"), 'regex': fn.FLOAT_REGEX, - 'evalFunc': D, + 'evalFunc': decimal.Decimal, 'compactHeight': True, # manually remove extra margin outside of text } self.decOpts = ['step', 'minStep'] - self.val = D(asUnicode(value)) ## Value is precise decimal. Ordinary math not allowed. + self.val = decimal.Decimal(asUnicode(value)) ## Value is precise decimal. Ordinary math not allowed. self.updateText() self.skipValidate = False self.setCorrectionMode(self.CorrectionMode.CorrectToPreviousValue) @@ -183,7 +181,7 @@ class SpinBox(QtGui.QAbstractSpinBox): elif k == 'max': self.setMaximum(v, update=False) elif k in ['step', 'minStep']: - self.opts[k] = D(asUnicode(v)) + self.opts[k] = decimal.Decimal(asUnicode(v)) elif k == 'value': pass ## don't set value until bounds have been set elif k == 'format': @@ -236,7 +234,7 @@ class SpinBox(QtGui.QAbstractSpinBox): def setMaximum(self, m, update=True): """Set the maximum allowed value (or None for no limit)""" if m is not None: - m = D(asUnicode(m)) + m = decimal.Decimal(asUnicode(m)) self.opts['bounds'][1] = m if update: self.setValue() @@ -244,7 +242,7 @@ class SpinBox(QtGui.QAbstractSpinBox): def setMinimum(self, m, update=True): """Set the minimum allowed value (or None for no limit)""" if m is not None: - m = D(asUnicode(m)) + m = decimal.Decimal(asUnicode(m)) self.opts['bounds'][0] = m if update: self.setValue() @@ -359,8 +357,8 @@ class SpinBox(QtGui.QAbstractSpinBox): if self.opts['int']: value = int(value) - if not isinstance(value, D): - value = D(asUnicode(value)) + if not isinstance(value, decimal.Decimal): + value = decimal.Decimal(asUnicode(value)) prev, self.val = self.val, value changed = not fn.eq(value, prev) # use fn.eq to handle nan @@ -400,8 +398,8 @@ class SpinBox(QtGui.QAbstractSpinBox): if isinf(self.val) or isnan(self.val): return - n = D(int(n)) ## n must be integral number of steps. - s = [D(-1), D(1)][n >= 0] ## determine sign of step + n = decimal.Decimal(int(n)) ## n must be integral number of steps. + s = [decimal.Decimal(-1), decimal.Decimal(1)][n >= 0] ## determine sign of step val = self.val for i in range(int(abs(n))): @@ -410,11 +408,11 @@ class SpinBox(QtGui.QAbstractSpinBox): step = self.opts['minStep'] exp = None else: - vs = [D(-1), D(1)][val >= 0] - #exp = D(int(abs(val*(D('1.01')**(s*vs))).log10())) - fudge = D('1.01')**(s*vs) ## fudge factor. at some places, the step size depends on the step sign. + vs = [decimal.Decimal(-1), decimal.Decimal(1)][val >= 0] + #exp = decimal.Decimal(int(abs(val*(decimal.Decimal('1.01')**(s*vs))).log10())) + fudge = decimal.Decimal('1.01')**(s*vs) ## fudge factor. at some places, the step size depends on the step sign. exp = abs(val * fudge).log10().quantize(1, decimal.ROUND_FLOOR) - step = self.opts['step'] * D(10)**exp + step = self.opts['step'] * decimal.Decimal(10)**exp if 'minStep' in self.opts: step = max(step, self.opts['minStep']) val += s * step @@ -423,7 +421,7 @@ class SpinBox(QtGui.QAbstractSpinBox): val += s*self.opts['step'] if 'minStep' in self.opts and abs(val) < self.opts['minStep']: - val = D(0) + val = decimal.Decimal(0) self.setValue(val, delaySignal=True) ## note all steps (arrow buttons, wheel, up/down keys..) emit delayed signals only. def valueInRange(self, value): diff --git a/pyqtgraph/widgets/TreeWidget.py b/pyqtgraph/widgets/TreeWidget.py index a81c94d0..cadc2774 100644 --- a/pyqtgraph/widgets/TreeWidget.py +++ b/pyqtgraph/widgets/TreeWidget.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- from ..Qt import QtGui, QtCore -from weakref import * __all__ = ['TreeWidget', 'TreeWidgetItem'] diff --git a/pyqtgraph/widgets/ValueLabel.py b/pyqtgraph/widgets/ValueLabel.py index f5dcdbd5..c95688ef 100644 --- a/pyqtgraph/widgets/ValueLabel.py +++ b/pyqtgraph/widgets/ValueLabel.py @@ -1,5 +1,6 @@ +# -*- coding: utf-8 -*- from time import perf_counter -from ..Qt import QtCore, QtGui +from ..Qt import QtGui from .. import functions as fn __all__ = ['ValueLabel']