Deprecate unused/unnecessary modules (#1576)
* Deprecate ordereddict module * Import OrderedDict from collections module instead of pgcollections * Deprecate pgcollections module * Deprecate lru_cache module A simpler recipe exists from the standard library using OrderedDict. * Deprecate pil_fix module * Python 3.7 compatibility fix * Avoid or suppress deprecation warnings in tests
This commit is contained in:
parent
5210c55e67
commit
6519734932
@ -6,7 +6,7 @@ import subprocess
|
||||
from argparse import Namespace
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.Qt import QtGui, QtCore, QT_LIB
|
||||
from pyqtgraph.pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .utils import examples
|
||||
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
|
@ -11,7 +11,7 @@ as it can be converted to/from a string using repr and eval.
|
||||
|
||||
import re, os, sys, datetime
|
||||
import numpy
|
||||
from .pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from . import units
|
||||
from .python2_3 import asUnicode, basestring
|
||||
from .Qt import QtCore
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
import pytest
|
||||
import pyqtgraph as pg
|
||||
from pyqtgraph.ordereddict import OrderedDict
|
||||
from collections import OrderedDict
|
||||
pg.mkQApp()
|
||||
|
||||
import pyqtgraph.dockarea as da
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ..Qt import QtCore, QtGui, QT_LIB
|
||||
from .Node import *
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from ..widgets.TreeWidget import *
|
||||
from .. import FileDialog, DataTreeWidget
|
||||
|
||||
|
@ -3,7 +3,7 @@ from ..Qt import QtCore, QtGui, QtWidgets
|
||||
from ..graphicsItems.GraphicsObject import GraphicsObject
|
||||
from .. import functions as fn
|
||||
from .Terminal import *
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from ..debug import *
|
||||
import numpy as np
|
||||
import warnings
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .Node import Node
|
||||
|
||||
def isNodeClass(cls):
|
||||
|
@ -1,5 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ...pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
import os, types
|
||||
from ...debug import printExc
|
||||
from ..NodeLibrary import NodeLibrary, isNodeClass
|
||||
|
@ -21,7 +21,7 @@ from . import debug, reload
|
||||
from .Qt import QtGui, QtCore, QT_LIB, QtVersion
|
||||
from . import Qt
|
||||
from .metaarray import MetaArray
|
||||
from .pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .python2_3 import asUnicode, basestring
|
||||
|
||||
Colors = {
|
||||
|
@ -4,7 +4,7 @@ import time
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from .AxisItem import AxisItem
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
__all__ = ['DateAxisItem']
|
||||
|
||||
|
@ -7,7 +7,7 @@ from .. import functions as fn
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from .GraphicsWidget import GraphicsWidget
|
||||
from ..widgets.SpinBox import SpinBox
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from ..colormap import ColorMap
|
||||
|
||||
translate = QtCore.QCoreApplication.translate
|
||||
|
@ -1,4 +1,5 @@
|
||||
import warnings
|
||||
from collections import OrderedDict
|
||||
from functools import reduce
|
||||
from ..Qt import QtGui, QtCore, isQObjectAlive
|
||||
from ..GraphicsScene import GraphicsScene
|
||||
@ -6,7 +7,29 @@ from ..Point import Point
|
||||
from .. import functions as fn
|
||||
import weakref
|
||||
import operator
|
||||
from ..util.lru_cache import LRUCache
|
||||
|
||||
|
||||
# Recipe from https://docs.python.org/3.8/library/collections.html#collections.OrderedDict
|
||||
# slightly adapted for Python 3.7 compatibility
|
||||
class LRU(OrderedDict):
|
||||
'Limit size, evicting the least recently looked-up key when full'
|
||||
|
||||
def __init__(self, maxsize=128, *args, **kwds):
|
||||
self.maxsize = maxsize
|
||||
super().__init__(*args, **kwds)
|
||||
|
||||
def __getitem__(self, key):
|
||||
value = super().__getitem__(key)
|
||||
self.move_to_end(key)
|
||||
return value
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
if key in self:
|
||||
self.move_to_end(key)
|
||||
super().__setitem__(key, value)
|
||||
if len(self) > self.maxsize:
|
||||
oldest = next(iter(self))
|
||||
del self[oldest]
|
||||
|
||||
|
||||
class GraphicsItem(object):
|
||||
@ -20,7 +43,7 @@ class GraphicsItem(object):
|
||||
|
||||
The GraphicsView system places a lot of emphasis on the notion that the graphics within the scene should be device independent--you should be able to take the same graphics and display them on screens of different resolutions, printers, export to SVG, etc. This is nice in principle, but causes me a lot of headache in practice. It means that I have to circumvent all the device-independent expectations any time I want to operate in pixel coordinates rather than arbitrary scene coordinates. A lot of the code in GraphicsItem is devoted to this task--keeping track of view widgets and device transforms, computing the size and shape of a pixel in local item coordinates, etc. Note that in item coordinates, a pixel does not have to be square or even rectangular, so just asking how to increase a bounding rect by 2px can be a rather complex task.
|
||||
"""
|
||||
_pixelVectorGlobalCache = LRUCache(100, 70)
|
||||
_pixelVectorGlobalCache = LRU(100)
|
||||
|
||||
def __init__(self, register=None):
|
||||
if not hasattr(self, '_qtBaseClass'):
|
||||
|
@ -14,7 +14,7 @@ from .. import functions as fn
|
||||
from .GraphicsItem import GraphicsItem
|
||||
from .GraphicsObject import GraphicsObject
|
||||
from .. import getConfigOption
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .. import debug
|
||||
from ..python2_3 import basestring
|
||||
|
||||
|
@ -20,6 +20,12 @@
|
||||
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
# OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"OrderedDict is in the standard library for supported versions of Python. Will be removed in 0.13",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
import sys
|
||||
if sys.version[0] > '2':
|
||||
from collections import OrderedDict
|
||||
|
@ -2,7 +2,7 @@
|
||||
from .. import functions as fn
|
||||
from ..Qt import QtGui, QtCore
|
||||
import os, weakref, re
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from ..python2_3 import asUnicode, basestring
|
||||
from .ParameterItem import ParameterItem
|
||||
import warnings
|
||||
|
@ -1,4 +1,4 @@
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
import numpy as np
|
||||
import copy
|
||||
|
||||
|
@ -8,7 +8,7 @@ from ..widgets.ColorButton import ColorButton
|
||||
from ..colormap import ColorMap
|
||||
from .. import icons as icons
|
||||
from .. import functions as fn
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
|
||||
class WidgetParameterItem(ParameterItem):
|
||||
|
@ -10,15 +10,17 @@ Includes:
|
||||
- ThreadsafeDict, ThreadsafeList - Self-mutexed data structures
|
||||
"""
|
||||
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"None of these are used in pyqtgraph. Will be removed in 0.13",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
import threading
|
||||
import sys
|
||||
import copy
|
||||
|
||||
try:
|
||||
from collections import OrderedDict
|
||||
except ImportError:
|
||||
# fallback: try to use the ordereddict backport when using python 2.6
|
||||
from ordereddict import OrderedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
try:
|
||||
from collections.abc import Sequence
|
||||
|
@ -1,3 +1,9 @@
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"No longer used in pyqtgraph. Will be removed in 0.13",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
import operator
|
||||
import sys
|
||||
import itertools
|
||||
|
@ -5,6 +5,12 @@ This works by patching objects in the PIL namespace; no files are
|
||||
modified.
|
||||
"""
|
||||
|
||||
import warnings
|
||||
warnings.warn(
|
||||
"Not used in pyqtgraph. Will be removed in 0.13",
|
||||
DeprecationWarning, stacklevel=2
|
||||
)
|
||||
|
||||
from PIL import Image
|
||||
|
||||
if Image.VERSION == '1.1.7':
|
||||
|
@ -1,4 +1,9 @@
|
||||
from pyqtgraph.util.lru_cache import LRUCache
|
||||
import warnings
|
||||
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
from pyqtgraph.util.lru_cache import LRUCache
|
||||
|
||||
|
||||
def testLRU():
|
||||
lru = LRUCache(2, 1)
|
||||
|
@ -1,7 +1,7 @@
|
||||
from ..Qt import QtGui, QtCore
|
||||
from .. import parametertree as ptree
|
||||
import numpy as np
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .. import functions as fn
|
||||
|
||||
__all__ = ['ColorMapWidget']
|
||||
|
@ -1,7 +1,7 @@
|
||||
import sys
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..SignalProxy import SignalProxy
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from ..python2_3 import asUnicode, basestring
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from ..Qt import QtGui, QtCore
|
||||
from .. import parametertree as ptree
|
||||
import numpy as np
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .. import functions as fn
|
||||
from ..python2_3 import basestring
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .TableWidget import TableWidget
|
||||
from ..python2_3 import asUnicode
|
||||
import types, traceback
|
||||
|
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from ..Qt import QtGui, QtCore
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
from .DataTreeWidget import DataTreeWidget
|
||||
from .. import functions as fn
|
||||
import types, traceback
|
||||
|
@ -7,7 +7,7 @@ from .. import functions as fn
|
||||
from .. import getConfigOption
|
||||
from ..graphicsItems.TextItem import TextItem
|
||||
import numpy as np
|
||||
from ..pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
__all__ = ['ScatterPlotWidget']
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import pyqtgraph as pg
|
||||
import numpy as np
|
||||
from pyqtgraph.pgcollections import OrderedDict
|
||||
from collections import OrderedDict
|
||||
|
||||
app = pg.mkQApp()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user