Import from python2_3 for all uses of basestring, cmp, and xrange
This commit is contained in:
parent
b549b93ade
commit
0976991efd
@ -8,6 +8,7 @@ if __name__ == "__main__" and (__package__ is None or __package__==''):
|
||||
|
||||
from . import initExample
|
||||
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5
|
||||
from pyqtgraph.python2_3 import basestring
|
||||
import pyqtgraph as pg
|
||||
|
||||
if USE_PYSIDE:
|
||||
|
@ -14,11 +14,11 @@ to avoid re-reading the entire visible waveform at every update.
|
||||
|
||||
import initExample ## Add path to library (just for examples; you do not need this)
|
||||
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
import sys, os
|
||||
import numpy as np
|
||||
import h5py
|
||||
import sys, os
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtCore, QtGui
|
||||
|
||||
pg.mkQApp()
|
||||
|
||||
|
@ -23,8 +23,8 @@ def plot():
|
||||
pts = 100
|
||||
x = np.linspace(0, 0.8, pts)
|
||||
y = np.random.random(size=pts)*0.8
|
||||
for i in xrange(n):
|
||||
for j in xrange(n):
|
||||
for i in range(n):
|
||||
for j in range(n):
|
||||
## calling PlotWidget.plot() generates a PlotDataItem, which
|
||||
## has a bit more overhead than PlotCurveItem, which is all
|
||||
## we need here. This overhead adds up quickly and makes a big
|
||||
|
@ -1,9 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import initExample ## Add path to library (just for examples; you do not need this)
|
||||
|
||||
import time
|
||||
import numpy as np
|
||||
import pyqtgraph.multiprocess as mp
|
||||
import pyqtgraph as pg
|
||||
import time
|
||||
from pyqtgraph.python2_3 import xrange
|
||||
|
||||
print( "\n=================\nParallelize")
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
import numpy as np
|
||||
import collections
|
||||
import sys, os
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtGui, QtCore
|
||||
from pyqtgraph.parametertree import Parameter, ParameterTree
|
||||
from pyqtgraph.parametertree import types as pTypes
|
||||
import pyqtgraph.configfile
|
||||
import numpy as np
|
||||
import collections
|
||||
import sys, os
|
||||
|
||||
from pyqtgraph.python2_3 import xrange
|
||||
|
||||
|
||||
class RelativityGUI(QtGui.QWidget):
|
||||
|
@ -1,12 +1,13 @@
|
||||
from ..Qt import QtCore, QtGui
|
||||
from ..python2_3 import sortList
|
||||
import weakref
|
||||
from ..Qt import QtCore, QtGui
|
||||
from ..python2_3 import sortList, cmp
|
||||
from ..Point import Point
|
||||
from .. import functions as fn
|
||||
from .. import ptime as ptime
|
||||
from .mouseEvents import *
|
||||
from .. import debug as debug
|
||||
|
||||
|
||||
if hasattr(QtCore, 'PYQT_VERSION'):
|
||||
try:
|
||||
import sip
|
||||
|
@ -346,7 +346,7 @@ def exit():
|
||||
|
||||
## close file handles
|
||||
if sys.platform == 'darwin':
|
||||
for fd in xrange(3, 4096):
|
||||
for fd in range(3, 4096):
|
||||
if fd not in [7]: # trying to close 7 produces an illegal instruction on the Mac.
|
||||
os.close(fd)
|
||||
else:
|
||||
|
@ -1,5 +1,7 @@
|
||||
import numpy as np
|
||||
from .Qt import QtGui, QtCore
|
||||
from .python2_3 import basestring
|
||||
|
||||
|
||||
class ColorMap(object):
|
||||
"""
|
||||
|
@ -10,14 +10,15 @@ as it can be converted to/from a string using repr and eval.
|
||||
"""
|
||||
|
||||
import re, os, sys
|
||||
import numpy
|
||||
from .pgcollections import OrderedDict
|
||||
GLOBAL_PATH = None # so not thread safe.
|
||||
from . import units
|
||||
from .python2_3 import asUnicode
|
||||
from .python2_3 import asUnicode, basestring
|
||||
from .Qt import QtCore
|
||||
from .Point import Point
|
||||
from .colormap import ColorMap
|
||||
import numpy
|
||||
GLOBAL_PATH = None # so not thread safe.
|
||||
|
||||
|
||||
class ParseError(Exception):
|
||||
def __init__(self, message, lineNum, line, fileName=None):
|
||||
|
@ -1,16 +1,17 @@
|
||||
import sys, re, os, time, traceback, subprocess
|
||||
import pickle
|
||||
|
||||
from ..Qt import QtCore, QtGui, USE_PYSIDE, USE_PYQT5
|
||||
import sys, re, os, time, traceback, subprocess
|
||||
from ..python2_3 import basestring
|
||||
from .. import exceptionHandling as exceptionHandling
|
||||
from .. import getConfigOption
|
||||
if USE_PYSIDE:
|
||||
from . import template_pyside as template
|
||||
elif USE_PYQT5:
|
||||
from . import template_pyqt5 as template
|
||||
else:
|
||||
from . import template_pyqt as template
|
||||
|
||||
from .. import exceptionHandling as exceptionHandling
|
||||
import pickle
|
||||
from .. import getConfigOption
|
||||
|
||||
|
||||
class ConsoleWidget(QtGui.QWidget):
|
||||
"""
|
||||
|
@ -723,7 +723,6 @@ class ObjTracker(object):
|
||||
for k in self.startCount:
|
||||
c1[k] = c1.get(k, 0) - self.startCount[k]
|
||||
typs = list(c1.keys())
|
||||
#typs.sort(lambda a,b: cmp(c1[a], c1[b]))
|
||||
typs.sort(key=lambda a: c1[a])
|
||||
for t in typs:
|
||||
if c1[t] == 0:
|
||||
@ -824,7 +823,6 @@ class ObjTracker(object):
|
||||
c = count.get(typ, [0,0])
|
||||
count[typ] = [c[0]+1, c[1]+objectSize(obj)]
|
||||
typs = list(count.keys())
|
||||
#typs.sort(lambda a,b: cmp(count[a][1], count[b][1]))
|
||||
typs.sort(key=lambda a: count[a][1])
|
||||
|
||||
for t in typs:
|
||||
|
@ -1,17 +1,11 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import weakref
|
||||
from ..Qt import QtCore, QtGui
|
||||
from .Container import *
|
||||
from .DockDrop import *
|
||||
from .Dock import Dock
|
||||
from .. import debug as debug
|
||||
import weakref
|
||||
|
||||
## TODO:
|
||||
# - containers should be drop areas, not docks. (but every slot within a container must have its own drop areas?)
|
||||
# - drop between tabs
|
||||
# - nest splitters inside tab boxes, etc.
|
||||
|
||||
|
||||
from ..python2_3 import basestring
|
||||
|
||||
|
||||
class DockArea(Container, QtGui.QWidget, DockDrop):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from ..widgets.FileDialog import FileDialog
|
||||
from ..Qt import QtGui, QtCore, QtSvg
|
||||
from ..python2_3 import asUnicode
|
||||
from ..python2_3 import asUnicode, basestring
|
||||
from ..GraphicsScene import GraphicsScene
|
||||
import os, re
|
||||
LastExportDirectory = None
|
||||
|
@ -352,7 +352,6 @@ class Flowchart(Node):
|
||||
#tdeps[t] = lastNode
|
||||
if lastInd is not None:
|
||||
dels.append((lastInd+1, t))
|
||||
#dels.sort(lambda a,b: cmp(b[0], a[0]))
|
||||
dels.sort(key=lambda a: a[0], reverse=True)
|
||||
for i, t in dels:
|
||||
ops.insert(i, ('d', t))
|
||||
@ -467,7 +466,6 @@ class Flowchart(Node):
|
||||
self.clear()
|
||||
Node.restoreState(self, state)
|
||||
nodes = state['nodes']
|
||||
#nodes.sort(lambda a, b: cmp(a['pos'][0], b['pos'][0]))
|
||||
nodes.sort(key=lambda a: a['pos'][0])
|
||||
for n in nodes:
|
||||
if n['name'] in self._nodes:
|
||||
|
@ -1,11 +1,11 @@
|
||||
# -*- 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 *
|
||||
import numpy as np
|
||||
|
||||
from ...python2_3 import xrange
|
||||
from ... import PolyLineROI
|
||||
from ... import Point
|
||||
from ... import metaarray as metaarray
|
||||
|
@ -1,5 +1,7 @@
|
||||
import numpy as np
|
||||
from ...metaarray import MetaArray
|
||||
from ...python2_3 import basestring, xrange
|
||||
|
||||
|
||||
def downsample(data, n, axis=0, xvals='subsample'):
|
||||
"""Downsample by averaging points together across axis.
|
||||
|
@ -6,7 +6,7 @@ Distributed under MIT/X11 license. See license.txt for more infomation.
|
||||
"""
|
||||
|
||||
from __future__ import division
|
||||
from .python2_3 import asUnicode
|
||||
from .python2_3 import asUnicode, basestring
|
||||
from .Qt import QtGui, QtCore, USE_PYSIDE
|
||||
Colors = {
|
||||
'b': QtGui.QColor(0,0,255,255),
|
||||
|
@ -1,14 +1,15 @@
|
||||
import weakref
|
||||
import numpy as np
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..python2_3 import sortList
|
||||
from .. import functions as fn
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from .GraphicsWidget import GraphicsWidget
|
||||
from ..widgets.SpinBox import SpinBox
|
||||
import weakref
|
||||
from ..pgcollections import OrderedDict
|
||||
from ..colormap import ColorMap
|
||||
from ..python2_3 import cmp
|
||||
|
||||
import numpy as np
|
||||
|
||||
__all__ = ['TickSliderItem', 'GradientEditorItem']
|
||||
|
||||
@ -26,8 +27,6 @@ Gradients = OrderedDict([
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class TickSliderItem(GraphicsWidget):
|
||||
## public class
|
||||
"""**Bases:** :class:`GraphicsWidget <pyqtgraph.GraphicsWidget>`
|
||||
|
@ -1,13 +1,14 @@
|
||||
import numpy as np
|
||||
from .. import metaarray as metaarray
|
||||
from ..Qt import QtCore
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from .PlotCurveItem import PlotCurveItem
|
||||
from .ScatterPlotItem import ScatterPlotItem
|
||||
import numpy as np
|
||||
from .. import functions as fn
|
||||
from .. import debug as debug
|
||||
from .. import getConfigOption
|
||||
|
||||
|
||||
class PlotDataItem(GraphicsObject):
|
||||
"""
|
||||
**Bases:** :class:`GraphicsObject <pyqtgraph.GraphicsObject>`
|
||||
|
@ -16,22 +16,14 @@ This class is very heavily featured:
|
||||
- Control panel with a huge feature set including averaging, decimation,
|
||||
display, power spectrum, svg/png export, plot linking, and more.
|
||||
"""
|
||||
from ...Qt import QtGui, QtCore, QT_LIB
|
||||
from ... import pixmaps
|
||||
import sys
|
||||
|
||||
if QT_LIB == 'PyQt4':
|
||||
from .plotConfigTemplate_pyqt import *
|
||||
elif QT_LIB == 'PySide':
|
||||
from .plotConfigTemplate_pyside import *
|
||||
elif QT_LIB == 'PyQt5':
|
||||
from .plotConfigTemplate_pyqt5 import *
|
||||
|
||||
from ... import functions as fn
|
||||
from ...widgets.FileDialog import FileDialog
|
||||
import weakref
|
||||
import numpy as np
|
||||
import os
|
||||
from ...Qt import QtGui, QtCore, QT_LIB
|
||||
from ... import pixmaps
|
||||
from ... import functions as fn
|
||||
from ...widgets.FileDialog import FileDialog
|
||||
from .. PlotDataItem import PlotDataItem
|
||||
from .. ViewBox import ViewBox
|
||||
from .. AxisItem import AxisItem
|
||||
@ -41,6 +33,14 @@ from .. GraphicsWidget import GraphicsWidget
|
||||
from .. ButtonItem import ButtonItem
|
||||
from .. InfiniteLine import InfiniteLine
|
||||
from ...WidgetGroup import WidgetGroup
|
||||
from ...python2_3 import basestring
|
||||
|
||||
if QT_LIB == 'PyQt4':
|
||||
from .plotConfigTemplate_pyqt import *
|
||||
elif QT_LIB == 'PySide':
|
||||
from .plotConfigTemplate_pyside import *
|
||||
elif QT_LIB == 'PyQt5':
|
||||
from .plotConfigTemplate_pyqt5 import *
|
||||
|
||||
__all__ = ['PlotItem']
|
||||
|
||||
@ -773,14 +773,6 @@ class PlotItem(GraphicsWidget):
|
||||
y = pos.y() * sy
|
||||
|
||||
fh.write('<circle cx="%f" cy="%f" r="1" fill="#%s" stroke="none" fill-opacity="%f"/>\n' % (x, y, color, opacity))
|
||||
#fh.write('<path fill="none" stroke="#%s" stroke-opacity="%f" stroke-width="1" d="M%f,%f ' % (color, opacity, x[0], y[0]))
|
||||
#for i in xrange(1, len(x)):
|
||||
#fh.write('L%f,%f ' % (x[i], y[i]))
|
||||
|
||||
#fh.write('"/>')
|
||||
|
||||
## get list of curves, scatter plots
|
||||
|
||||
|
||||
fh.write("</svg>\n")
|
||||
|
||||
|
@ -1,8 +1,3 @@
|
||||
from ..Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5
|
||||
from ..Point import Point
|
||||
from .. import functions as fn
|
||||
from .GraphicsItem import GraphicsItem
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from itertools import starmap, repeat
|
||||
try:
|
||||
from itertools import imap
|
||||
@ -10,10 +5,15 @@ except ImportError:
|
||||
imap = map
|
||||
import numpy as np
|
||||
import weakref
|
||||
from ..Qt import QtGui, QtCore, USE_PYSIDE, USE_PYQT5
|
||||
from ..Point import Point
|
||||
from .. import functions as fn
|
||||
from .GraphicsItem import GraphicsItem
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from .. import getConfigOption
|
||||
from .. import debug as debug
|
||||
from ..pgcollections import OrderedDict
|
||||
from .. import debug
|
||||
from ..python2_3 import basestring
|
||||
|
||||
__all__ = ['ScatterPlotItem', 'SpotItem']
|
||||
|
||||
@ -455,8 +455,6 @@ class ScatterPlotItem(GraphicsObject):
|
||||
brushes = brushes[kargs['mask']]
|
||||
if len(brushes) != len(dataSet):
|
||||
raise Exception("Number of brushes does not match number of points (%d != %d)" % (len(brushes), len(dataSet)))
|
||||
#for i in xrange(len(brushes)):
|
||||
#self.data[i]['brush'] = fn.mkBrush(brushes[i], **kargs)
|
||||
dataSet['brush'] = brushes
|
||||
else:
|
||||
self.opts['brush'] = fn.mkBrush(*args, **kargs)
|
||||
@ -815,7 +813,6 @@ class ScatterPlotItem(GraphicsObject):
|
||||
#else:
|
||||
#print "No hit:", (x, y), (sx, sy)
|
||||
#print " ", (sx-s2x, sy-s2y), (sx+s2x, sy+s2y)
|
||||
#pts.sort(lambda a,b: cmp(b.zValue(), a.zValue()))
|
||||
return pts[::-1]
|
||||
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
from ...Qt import QtGui, QtCore
|
||||
from ...python2_3 import sortList
|
||||
import weakref
|
||||
import sys
|
||||
from copy import deepcopy
|
||||
import numpy as np
|
||||
from ...Qt import QtGui, QtCore
|
||||
from ...python2_3 import sortList, basestring, cmp
|
||||
from ...Point import Point
|
||||
from ... import functions as fn
|
||||
from .. ItemGroup import ItemGroup
|
||||
from .. GraphicsWidget import GraphicsWidget
|
||||
import weakref
|
||||
from copy import deepcopy
|
||||
from ... import debug as debug
|
||||
from ... import getConfigOption
|
||||
import sys
|
||||
from ...Qt import isQObjectAlive
|
||||
|
||||
__all__ = ['ViewBox']
|
||||
|
@ -10,10 +10,11 @@ new methods for slicing and indexing the array based on this meta data.
|
||||
More info at http://www.scipy.org/Cookbook/MetaArray
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
import types, copy, threading, os, re
|
||||
import pickle
|
||||
from functools import reduce
|
||||
import numpy as np
|
||||
from ..python2_3 import basestring
|
||||
#import traceback
|
||||
|
||||
## By default, the library will use HDF5 when writing files.
|
||||
|
@ -1,6 +1,8 @@
|
||||
import os, sys, time, multiprocessing, re
|
||||
from .processes import ForkedProcess
|
||||
from .remoteproxy import ClosedError
|
||||
from ..python2_3 import basestring, xrange
|
||||
|
||||
|
||||
class CanceledError(Exception):
|
||||
"""Raised when the progress dialog is canceled during a processing operation."""
|
||||
|
@ -1,7 +1,9 @@
|
||||
from ..Qt import QtGui, QtCore
|
||||
from .. import Transform3D
|
||||
from OpenGL.GL import *
|
||||
from OpenGL import GL
|
||||
from ..Qt import QtGui, QtCore
|
||||
from .. import Transform3D
|
||||
from ..python2_3 import basestring
|
||||
|
||||
|
||||
GLOptions = {
|
||||
'opaque': {
|
||||
|
@ -1,6 +1,8 @@
|
||||
import numpy as np
|
||||
from ..Qt import QtGui
|
||||
from .. import functions as fn
|
||||
import numpy as np
|
||||
from ..python2_3 import xrange
|
||||
|
||||
|
||||
class MeshData(object):
|
||||
"""
|
||||
|
@ -1,7 +1,7 @@
|
||||
from ..Qt import QtGui, QtCore
|
||||
import os, weakref, re
|
||||
from ..pgcollections import OrderedDict
|
||||
from ..python2_3 import asUnicode
|
||||
from ..python2_3 import asUnicode, basestring
|
||||
from .ParameterItem import ParameterItem
|
||||
|
||||
PARAM_TYPES = {}
|
||||
|
@ -6,6 +6,7 @@ Provides support for frozen environments as well.
|
||||
import os, sys, pickle
|
||||
from ..functions import makeQImage
|
||||
from ..Qt import QtGui
|
||||
from ..python2_3 import basestring
|
||||
if sys.version_info[0] == 2:
|
||||
from . import pixmapData_2 as pixmapData
|
||||
else:
|
||||
|
@ -40,10 +40,6 @@ def sortList(l, cmpFunc):
|
||||
l.sort(key=cmpToKey(cmpFunc))
|
||||
|
||||
if sys.version_info[0] == 3:
|
||||
import builtins
|
||||
builtins.basestring = str
|
||||
#builtins.asUnicode = asUnicode
|
||||
#builtins.sortList = sortList
|
||||
basestring = str
|
||||
def cmp(a,b):
|
||||
if a>b:
|
||||
@ -52,9 +48,11 @@ if sys.version_info[0] == 3:
|
||||
return -1
|
||||
else:
|
||||
return 0
|
||||
builtins.cmp = cmp
|
||||
builtins.xrange = range
|
||||
#else: ## don't use __builtin__ -- this confuses things like pyshell and ActiveState's lazy import recipe
|
||||
#import __builtin__
|
||||
#__builtin__.asUnicode = asUnicode
|
||||
#__builtin__.sortList = sortList
|
||||
xrange = range
|
||||
else:
|
||||
import __builtin__
|
||||
basestring = __builtin__.basestring
|
||||
cmp = __builtin__.cmp
|
||||
xrange = __builtin__.xrange
|
||||
|
||||
|
@ -7,6 +7,7 @@ import sys, re
|
||||
|
||||
from .colorama.winterm import WinTerm, WinColor, WinStyle
|
||||
from .colorama.win32 import windll
|
||||
from ..python2_3 import basestring
|
||||
|
||||
_WIN = sys.platform.startswith('win')
|
||||
if windll is not None:
|
||||
|
@ -1,8 +1,9 @@
|
||||
import sys
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..SignalProxy import SignalProxy
|
||||
import sys
|
||||
from ..pgcollections import OrderedDict
|
||||
from ..python2_3 import asUnicode
|
||||
from ..python2_3 import asUnicode, basestring
|
||||
|
||||
|
||||
class ComboBox(QtGui.QComboBox):
|
||||
"""Extends QComboBox to add extra functionality.
|
||||
|
@ -1,13 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..python2_3 import asUnicode
|
||||
|
||||
import numpy as np
|
||||
try:
|
||||
import metaarray
|
||||
HAVE_METAARRAY = True
|
||||
except ImportError:
|
||||
HAVE_METAARRAY = False
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..python2_3 import asUnicode, basestring
|
||||
from .. import metaarray
|
||||
|
||||
|
||||
__all__ = ['TableWidget']
|
||||
@ -207,7 +202,7 @@ class TableWidget(QtGui.QTableWidget):
|
||||
return lambda d: d.__iter__(), None
|
||||
elif isinstance(data, dict):
|
||||
return lambda d: iter(d.values()), list(map(asUnicode, data.keys()))
|
||||
elif HAVE_METAARRAY and (hasattr(data, 'implements') and data.implements('MetaArray')):
|
||||
elif (hasattr(data, 'implements') and data.implements('MetaArray')):
|
||||
if data.axisHasColumns(0):
|
||||
header = [asUnicode(data.columnName(0, i)) for i in range(data.shape[0])]
|
||||
elif data.axisHasValues(0):
|
||||
@ -491,14 +486,13 @@ if __name__ == '__main__':
|
||||
|
||||
t.setData(ll)
|
||||
|
||||
if HAVE_METAARRAY:
|
||||
ma = metaarray.MetaArray(np.ones((20, 3)), info=[
|
||||
{'values': np.linspace(1, 5, 20)},
|
||||
{'cols': [
|
||||
{'name': 'x'},
|
||||
{'name': 'y'},
|
||||
{'name': 'z'},
|
||||
]}
|
||||
])
|
||||
t.setData(ma)
|
||||
ma = metaarray.MetaArray(np.ones((20, 3)), info=[
|
||||
{'values': np.linspace(1, 5, 20)},
|
||||
{'cols': [
|
||||
{'name': 'x'},
|
||||
{'name': 'y'},
|
||||
{'name': 'z'},
|
||||
]}
|
||||
])
|
||||
t.setData(ma)
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ..Qt import QtGui, QtCore
|
||||
from weakref import *
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..python2_3 import xrange
|
||||
|
||||
|
||||
__all__ = ['TreeWidget', 'TreeWidgetItem']
|
||||
|
||||
|
||||
class TreeWidget(QtGui.QTreeWidget):
|
||||
"""Extends QTreeWidget to allow internal drag/drop with widgets in the tree.
|
||||
Also maintains the expanded state of subtrees as they are moved.
|
||||
|
Loading…
Reference in New Issue
Block a user