From 81baa182c53f5b45862b0e56132c6cd9b0a69fc1 Mon Sep 17 00:00:00 2001 From: KIU Shueng Chuan Date: Sun, 20 Jun 2021 10:51:44 +0800 Subject: [PATCH] add __all__ to various files --- pyqtgraph/ThreadsafeTimer.py | 2 ++ pyqtgraph/__init__.py | 7 +++++- pyqtgraph/functions.py | 25 +++++++++++++++++++ pyqtgraph/graphicsItems/FillBetweenItem.py | 2 ++ pyqtgraph/graphicsItems/GraphicsItem.py | 1 + .../graphicsItems/GraphicsWidgetAnchor.py | 1 + pyqtgraph/graphicsItems/HistogramLUTItem.py | 1 + pyqtgraph/graphicsItems/IsocurveItem.py | 1 + pyqtgraph/graphicsItems/NonUniformImage.py | 1 + pyqtgraph/graphicsItems/PlotDataItem.py | 1 + pyqtgraph/graphicsItems/PlotItem/PlotItem.py | 4 ++- pyqtgraph/graphicsItems/PlotItem/__init__.py | 2 ++ pyqtgraph/graphicsItems/TargetItem.py | 1 + pyqtgraph/graphicsItems/TextItem.py | 1 + pyqtgraph/graphicsItems/ViewBox/__init__.py | 2 ++ pyqtgraph/graphicsWindows.py | 2 ++ pyqtgraph/imageview/__init__.py | 2 ++ pyqtgraph/widgets/ComboBox.py | 1 + pyqtgraph/widgets/GroupBox.py | 1 + pyqtgraph/widgets/MatplotlibWidget.py | 2 ++ pyqtgraph/widgets/RawImageWidget.py | 2 ++ tests/exporters/test_csv.py | 5 ++-- tests/exporters/test_matplotlib.py | 2 +- tests/graphicsItems/test_ImageItem.py | 2 +- tests/test_ref_cycles.py | 2 +- 25 files changed, 66 insertions(+), 7 deletions(-) diff --git a/pyqtgraph/ThreadsafeTimer.py b/pyqtgraph/ThreadsafeTimer.py index 47bf3ed5..2dc4b9bd 100644 --- a/pyqtgraph/ThreadsafeTimer.py +++ b/pyqtgraph/ThreadsafeTimer.py @@ -1,6 +1,8 @@ # -*- coding: utf-8 -*- from .Qt import QtCore, QtGui +__all__ = ['ThreadsafeTimer'] + class ThreadsafeTimer(QtCore.QObject): """ Thread-safe replacement for QTimer. diff --git a/pyqtgraph/__init__.py b/pyqtgraph/__init__.py index 3edd7a20..d69667c7 100644 --- a/pyqtgraph/__init__.py +++ b/pyqtgraph/__init__.py @@ -10,7 +10,7 @@ __version__ = '0.12.1' ## 'Qt' is a local module; it is intended mainly to cover up the differences ## between PyQt4 and PySide. -from .Qt import QtGui, mkQApp +from .Qt import QtCore, QtGui, mkQApp from .Qt import exec_ as exec ## not really safe--If we accidentally create another QApplication, the process hangs (and it is very difficult to trace the cause) @@ -280,6 +280,11 @@ from .ptime import time from .Qt import isQObjectAlive from .ThreadsafeTimer import * +# indirect imports used within library +from .GraphicsScene import GraphicsScene +from .python2_3 import asUnicode +from .util.cupy_helper import getCupy + ############################################################## ## PyQt and PySide both are prone to crashing on exit. diff --git a/pyqtgraph/functions.py b/pyqtgraph/functions.py index 7706a44c..b08b1d3c 100644 --- a/pyqtgraph/functions.py +++ b/pyqtgraph/functions.py @@ -26,6 +26,31 @@ from .metaarray import MetaArray from collections import OrderedDict from .python2_3 import asUnicode, basestring +# in order of appearance in this file. +# add new functions to this list only if they are to reside in pg namespace. +__all__ = [ + 'siScale', 'siFormat', 'siParse', 'siEval', 'siApply', + 'Color', 'mkColor', 'mkBrush', 'mkPen', 'hsvColor', + 'CIELabColor', 'colorCIELab', 'colorDistance', + 'colorTuple', 'colorStr', 'intColor', 'glColor', + 'makeArrowPath', 'eq', + 'affineSliceCoords', 'affineSlice', + 'interweaveArrays', 'interpolateArray', 'subArray', + 'transformToArray', 'transformCoordinates', + 'solve3DTransform', 'solveBilinearTransform', + 'clip_scalar', 'clip_array', 'rescaleData', 'applyLookupTable', + 'makeRGBA', 'makeARGB', + # 'try_fastpath_argb', 'ndarray_to_qimage', + 'makeQImage', + # 'qimage_to_ndarray', + 'imageToArray', 'colorToAlpha', + 'gaussianFilter', 'downsample', 'arrayToQPath', + # 'ndarray_from_qpolygonf', 'create_qpolygonf', 'arrayToQPolygonF', + 'isocurve', 'traceImage', 'isosurface', + 'invertQTransform', + 'pseudoScatter', 'toposort', 'disconnect', 'SignalBlock'] + + Colors = { 'b': QtGui.QColor(0,0,255,255), 'g': QtGui.QColor(0,255,0,255), diff --git a/pyqtgraph/graphicsItems/FillBetweenItem.py b/pyqtgraph/graphicsItems/FillBetweenItem.py index 02c5feca..8c09f7a0 100644 --- a/pyqtgraph/graphicsItems/FillBetweenItem.py +++ b/pyqtgraph/graphicsItems/FillBetweenItem.py @@ -3,6 +3,8 @@ from .. import functions as fn from .PlotDataItem import PlotDataItem from .PlotCurveItem import PlotCurveItem +__all__ = ['FillBetweenItem'] + class FillBetweenItem(QtGui.QGraphicsPathItem): """ GraphicsItem filling the space between two PlotDataItems. diff --git a/pyqtgraph/graphicsItems/GraphicsItem.py b/pyqtgraph/graphicsItems/GraphicsItem.py index cc3b06da..8db52fe9 100644 --- a/pyqtgraph/graphicsItems/GraphicsItem.py +++ b/pyqtgraph/graphicsItems/GraphicsItem.py @@ -9,6 +9,7 @@ from .. import functions as fn import weakref import operator +__all__ = ['GraphicsItem'] # Recipe from https://docs.python.org/3.8/library/collections.html#collections.OrderedDict # slightly adapted for Python 3.7 compatibility diff --git a/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py b/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py index 251bc0c8..78eed4f2 100644 --- a/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py +++ b/pyqtgraph/graphicsItems/GraphicsWidgetAnchor.py @@ -1,6 +1,7 @@ from ..Qt import QtGui, QtCore from ..Point import Point +__all__ = ['GraphicsWidgetAnchor'] class GraphicsWidgetAnchor(object): """ diff --git a/pyqtgraph/graphicsItems/HistogramLUTItem.py b/pyqtgraph/graphicsItems/HistogramLUTItem.py index e71d5008..dbe4f27a 100644 --- a/pyqtgraph/graphicsItems/HistogramLUTItem.py +++ b/pyqtgraph/graphicsItems/HistogramLUTItem.py @@ -12,6 +12,7 @@ from .ViewBox import * from .GradientEditorItem import * from .LinearRegionItem import * from .PlotDataItem import * +from .PlotCurveItem import * from .AxisItem import * from .GridItem import * from ..Point import Point diff --git a/pyqtgraph/graphicsItems/IsocurveItem.py b/pyqtgraph/graphicsItems/IsocurveItem.py index 03ebc69f..880cc1db 100644 --- a/pyqtgraph/graphicsItems/IsocurveItem.py +++ b/pyqtgraph/graphicsItems/IsocurveItem.py @@ -3,6 +3,7 @@ from .GraphicsObject import * from .. import functions as fn from ..Qt import QtGui, QtCore +__all__ = ['IsocurveItem'] class IsocurveItem(GraphicsObject): """ diff --git a/pyqtgraph/graphicsItems/NonUniformImage.py b/pyqtgraph/graphicsItems/NonUniformImage.py index fc42bf27..9647e37e 100644 --- a/pyqtgraph/graphicsItems/NonUniformImage.py +++ b/pyqtgraph/graphicsItems/NonUniformImage.py @@ -6,6 +6,7 @@ from .GraphicsObject import GraphicsObject from .. import mkBrush, mkPen from .. import functions as fn +__all__ = ['NonUniformImage'] class NonUniformImage(GraphicsObject): """ diff --git a/pyqtgraph/graphicsItems/PlotDataItem.py b/pyqtgraph/graphicsItems/PlotDataItem.py index 5e269bb2..c6413319 100644 --- a/pyqtgraph/graphicsItems/PlotDataItem.py +++ b/pyqtgraph/graphicsItems/PlotDataItem.py @@ -11,6 +11,7 @@ from .. import functions as fn from .. import debug as debug from .. import getConfigOption +__all__ = ['PlotDataItem'] class PlotDataItem(GraphicsObject): """ diff --git a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py index 522cee03..0db2abd6 100644 --- a/pyqtgraph/graphicsItems/PlotItem/PlotItem.py +++ b/pyqtgraph/graphicsItems/PlotItem/PlotItem.py @@ -14,9 +14,11 @@ from ..InfiniteLine import InfiniteLine from ..LabelItem import LabelItem from ..LegendItem import LegendItem from ..PlotDataItem import PlotDataItem +from ..PlotCurveItem import PlotCurveItem +from ..ScatterPlotItem import ScatterPlotItem from ..ViewBox import ViewBox from ... import functions as fn -from ... import icons, PlotCurveItem, ScatterPlotItem +from ... import icons from ...Qt import QtGui, QtCore, QT_LIB from ...WidgetGroup import WidgetGroup from ...python2_3 import basestring diff --git a/pyqtgraph/graphicsItems/PlotItem/__init__.py b/pyqtgraph/graphicsItems/PlotItem/__init__.py index d797978c..5cdfea6e 100644 --- a/pyqtgraph/graphicsItems/PlotItem/__init__.py +++ b/pyqtgraph/graphicsItems/PlotItem/__init__.py @@ -1 +1,3 @@ from .PlotItem import PlotItem + +__all__ = ['PlotItem'] diff --git a/pyqtgraph/graphicsItems/TargetItem.py b/pyqtgraph/graphicsItems/TargetItem.py index ca8cf44d..9724e0c0 100644 --- a/pyqtgraph/graphicsItems/TargetItem.py +++ b/pyqtgraph/graphicsItems/TargetItem.py @@ -10,6 +10,7 @@ from .ViewBox import ViewBox import string import warnings +__all__ = ['TargetItem', 'TargetLabel'] class TargetItem(UIGraphicsItem): """Draws a draggable target symbol (circle plus crosshair). diff --git a/pyqtgraph/graphicsItems/TextItem.py b/pyqtgraph/graphicsItems/TextItem.py index 9b5dff8f..d71f9f34 100644 --- a/pyqtgraph/graphicsItems/TextItem.py +++ b/pyqtgraph/graphicsItems/TextItem.py @@ -4,6 +4,7 @@ from ..Point import Point from .. import functions as fn from .GraphicsObject import GraphicsObject +__all__ = ['TextItem'] class TextItem(GraphicsObject): """ diff --git a/pyqtgraph/graphicsItems/ViewBox/__init__.py b/pyqtgraph/graphicsItems/ViewBox/__init__.py index 685a314d..07b90fb1 100644 --- a/pyqtgraph/graphicsItems/ViewBox/__init__.py +++ b/pyqtgraph/graphicsItems/ViewBox/__init__.py @@ -1 +1,3 @@ from .ViewBox import ViewBox + +__all__ = ['ViewBox'] diff --git a/pyqtgraph/graphicsWindows.py b/pyqtgraph/graphicsWindows.py index 02206d35..dd42880b 100644 --- a/pyqtgraph/graphicsWindows.py +++ b/pyqtgraph/graphicsWindows.py @@ -6,6 +6,8 @@ it is possible to place any widget into its own window by simply calling its show() method. """ +__all__ = ['GraphicsWindow', 'TabWindow', 'PlotWindow', 'ImageWindow'] + from .Qt import QtCore, QtGui, mkQApp from .widgets.PlotWidget import * from .imageview import * diff --git a/pyqtgraph/imageview/__init__.py b/pyqtgraph/imageview/__init__.py index 0060e823..47781939 100644 --- a/pyqtgraph/imageview/__init__.py +++ b/pyqtgraph/imageview/__init__.py @@ -4,3 +4,5 @@ Includes ROI plotting over time and image normalization. """ from .ImageView import ImageView + +__all__ = ['ImageView'] \ No newline at end of file diff --git a/pyqtgraph/widgets/ComboBox.py b/pyqtgraph/widgets/ComboBox.py index 5c977832..eb04dafc 100644 --- a/pyqtgraph/widgets/ComboBox.py +++ b/pyqtgraph/widgets/ComboBox.py @@ -4,6 +4,7 @@ from ..SignalProxy import SignalProxy from collections import OrderedDict from ..python2_3 import asUnicode, basestring +__all__ = ['ComboBox'] class ComboBox(QtGui.QComboBox): """Extends QComboBox to add extra functionality. diff --git a/pyqtgraph/widgets/GroupBox.py b/pyqtgraph/widgets/GroupBox.py index 53b07b41..233e3ae3 100644 --- a/pyqtgraph/widgets/GroupBox.py +++ b/pyqtgraph/widgets/GroupBox.py @@ -2,6 +2,7 @@ from ..Qt import QtGui, QtCore from .PathButton import PathButton from ..python2_3 import basestring +__all__ = ['GroupBox'] class GroupBox(QtGui.QGroupBox): """Subclass of QGroupBox that implements collapse handle. diff --git a/pyqtgraph/widgets/MatplotlibWidget.py b/pyqtgraph/widgets/MatplotlibWidget.py index b3868e8f..2c305397 100644 --- a/pyqtgraph/widgets/MatplotlibWidget.py +++ b/pyqtgraph/widgets/MatplotlibWidget.py @@ -6,6 +6,8 @@ from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as Navigatio from matplotlib.figure import Figure +__all__ = ['MatplotlibWidget'] + class MatplotlibWidget(QtGui.QWidget): """ Implements a Matplotlib figure inside a QWidget. diff --git a/pyqtgraph/widgets/RawImageWidget.py b/pyqtgraph/widgets/RawImageWidget.py index 1b404b72..2a12127f 100644 --- a/pyqtgraph/widgets/RawImageWidget.py +++ b/pyqtgraph/widgets/RawImageWidget.py @@ -18,6 +18,7 @@ except (ImportError, AttributeError): # AttributeError upon import HAVE_OPENGL = False +__all__ = ['RawImageWidget'] class RawImageWidget(QtGui.QWidget): """ @@ -78,6 +79,7 @@ class RawImageWidget(QtGui.QWidget): if HAVE_OPENGL: + __all__.append('RawImageGLWidget') class RawImageGLWidget(QOpenGLWidget): """ Similar to RawImageWidget, but uses a GL widget to do all drawing. diff --git a/tests/exporters/test_csv.py b/tests/exporters/test_csv.py index bcb7fcaf..c66d1b52 100644 --- a/tests/exporters/test_csv.py +++ b/tests/exporters/test_csv.py @@ -2,6 +2,7 @@ CSV export test """ from __future__ import division, print_function, absolute_import +import numpy as np import pyqtgraph as pg import csv import tempfile @@ -19,11 +20,11 @@ def test_CSVExporter(): plt.plot(y=y1, name='myPlot') y2 = [3,4,6,1,2,4,2,3,5,3,5,1,3] - x2 = pg.np.linspace(0, 1.0, len(y2)) + x2 = np.linspace(0, 1.0, len(y2)) plt.plot(x=x2, y=y2) y3 = [1,5,2,3,4,6,1,2,4,2,3,5,3] - x3 = pg.np.linspace(0, 1.0, len(y3)+1) + x3 = np.linspace(0, 1.0, len(y3)+1) plt.plot(x=x3, y=y3, stepMode="center") ex = pg.exporters.CSVExporter(plt.plotItem) diff --git a/tests/exporters/test_matplotlib.py b/tests/exporters/test_matplotlib.py index 3e3e98dd..1e4468b7 100644 --- a/tests/exporters/test_matplotlib.py +++ b/tests/exporters/test_matplotlib.py @@ -7,7 +7,7 @@ pytest.importorskip("matplotlib") app = pg.mkQApp() skip_qt6 = pytest.mark.skipif( - pg.QT_LIB in ["PySide6", "PyQt6"], + pg.Qt.QT_LIB in ["PySide6", "PyQt6"], reason= ( "Matplotlib has no Qt6 support yet, " "see https://github.com/matplotlib/matplotlib/pull/19255" diff --git a/tests/graphicsItems/test_ImageItem.py b/tests/graphicsItems/test_ImageItem.py index 99d70449..41802c4d 100644 --- a/tests/graphicsItems/test_ImageItem.py +++ b/tests/graphicsItems/test_ImageItem.py @@ -229,7 +229,7 @@ def test_setRect(): def test_dividebyzero(): - im = pg.image(pg.np.random.normal(size=(100,100))) + im = pg.image(np.random.normal(size=(100,100))) im.imageItem.setAutoDownsample(True) im.view.setRange(xRange=[-5+25, 5e+25],yRange=[-5e+25, 5e+25]) app.processEvents() diff --git a/tests/test_ref_cycles.py b/tests/test_ref_cycles.py index 986a2a14..8d84d772 100644 --- a/tests/test_ref_cycles.py +++ b/tests/test_ref_cycles.py @@ -37,7 +37,7 @@ def test_PlotWidget(): with warnings.catch_warnings(): warnings.simplefilter("ignore") w = pg.PlotWidget(*args, **kwds) - data = pg.np.array([1,5,2,4,3]) + data = np.array([1,5,2,4,3]) c = w.plot(data, name='stuff') w.addLegend()