From eb80dbc21621e2ed7bdd35b9f01bb1b9d7738c72 Mon Sep 17 00:00:00 2001 From: Philipp Sommer <philipp.sommer@hereon.de> Date: Tue, 23 Jan 2024 08:23:49 +0100 Subject: [PATCH] remove usage of pycompat module --- .gitignore | 2 ++ psyplot_gui/__init__.py | 5 +---- psyplot_gui/content_widget.py | 7 +++---- psyplot_gui/fmt_widget.py | 3 +-- psyplot_gui/help_explorer.py | 9 ++++----- psyplot_gui/main.py | 4 ++-- psyplot_gui/plot_creator.py | 3 +-- tests/test_plot_creator.py | 1 - 8 files changed, 14 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 875a53c..62c69db 100644 --- a/.gitignore +++ b/.gitignore @@ -77,3 +77,5 @@ target/ # conda build files ci/conda_recipe/psyplot-gui/meta.yaml ci/conda-recipe/recipe_append.yaml + +venv/ \ No newline at end of file diff --git a/psyplot_gui/__init__.py b/psyplot_gui/__init__.py index 31908a1..6b8326f 100644 --- a/psyplot_gui/__init__.py +++ b/psyplot_gui/__init__.py @@ -46,16 +46,13 @@ from itertools import chain from psyplot.config.rcsetup import get_configdir, safe_list from psyplot.docstring import docstrings from psyplot.warning import warn -from psyplot.compat.pycompat import map +from psyplot.utils import get_default_value from ._version import get_versions __version__ = get_versions()['version'] del get_versions - -from psyplot.compat.pycompat import get_default_value - __author__ = "Philipp S. Sommer" __copyright__ = """ Copyright (C) 2021 Helmholtz-Zentrum Hereon diff --git a/psyplot_gui/content_widget.py b/psyplot_gui/content_widget.py index cdec749..cfcfe32 100644 --- a/psyplot_gui/content_widget.py +++ b/psyplot_gui/content_widget.py @@ -43,7 +43,6 @@ from psyplot_gui.compat.qtcompat import ( QWidget, QPushButton, QHBoxLayout, QVBoxLayout, QTreeWidget, QTreeWidgetItem, QtCore, QMenu, QAction, Qt, QLabel, QScrollArea) from psyplot.config.rcsetup import safe_list -from psyplot.compat.pycompat import OrderedDict, map, range from psyplot.project import scp, gcp, Project from psyplot.data import ArrayList, InteractiveList from psyplot.utils import _TempBool @@ -241,9 +240,9 @@ class ProjectContent(QToolBox): This toolbox contains several :class:`PlotterList` that show the content of the current main and subproject""" - #: :class:`OrderedDict` containing the :class:`PlotterList` instances + #: :class:`dict` containing the :class:`PlotterList` instances #: of the different selection attributes - lists = OrderedDict() + lists = dict() @property def current_names(self): @@ -251,7 +250,7 @@ class ProjectContent(QToolBox): def __init__(self, *args, **kwargs): super(ProjectContent, self).__init__(*args, **kwargs) - self.lists = OrderedDict() + self.lists = dict() for attr in chain(['All'], sorted(Project._registered_plotters)): item = self.add_plotterlist(attr, force=(attr == 'All')) self.lists[attr] = item diff --git a/psyplot_gui/fmt_widget.py b/psyplot_gui/fmt_widget.py index b734217..bfc9b49 100644 --- a/psyplot_gui/fmt_widget.py +++ b/psyplot_gui/fmt_widget.py @@ -41,7 +41,6 @@ from psyplot_gui.compat.qtcompat import ( QStandardItemModel, QStandardItem, with_qt5) from psyplot_gui.plot_creator import CoordComboBox from psyplot_gui.config.rcsetup import rcParams -from psyplot.compat.pycompat import OrderedDict, map from psyplot_gui.common import DockMixin, get_icon, PyErrorMessage from psyplot.data import safe_list import psyplot.plotter as psyp @@ -390,7 +389,7 @@ class FormatoptionWidget(QWidget, DockMixin): grouped_fmts[fmto.group].append(fmto) for val in six.itervalues(grouped_fmts): val.sort(key=sorter) - grouped_fmts = OrderedDict( + grouped_fmts = dict( sorted(six.iteritems(grouped_fmts), key=lambda t: psyp.groups.get(t[0], t[0]))) fmt_groups = list(grouped_fmts.keys()) diff --git a/psyplot_gui/help_explorer.py b/psyplot_gui/help_explorer.py index 103b046..7da8b6b 100644 --- a/psyplot_gui/help_explorer.py +++ b/psyplot_gui/help_explorer.py @@ -35,7 +35,6 @@ import types import inspect import shutil from psyplot.docstring import indent, docstrings -from psyplot.compat.pycompat import OrderedDict from psyplot.utils import _temp_bool_prop from psyplot_gui.config.rcsetup import rcParams from psyplot_gui.compat.qtcompat import ( @@ -87,7 +86,7 @@ def html2file(url): p.path[int(sys.platform == 'win32'):])) -_viewers = OrderedDict() +_viewers = dict() logger = logging.getLogger(__name__) @@ -163,7 +162,7 @@ class UrlBrowser(QFrame): url_like_re = re.compile('^\w+://') - doc_urls = OrderedDict([ + doc_urls = dict([ ('startpage', 'https://startpage.com/'), ('psyplot', 'http://psyplot.github.io/psyplot/'), ('pyplot', 'http://matplotlib.org/api/pyplot_api.html'), @@ -955,7 +954,7 @@ class HelpExplorer(QWidget, DockMixin): #: The viewer classes used by the help explorer. :class:`HelpExplorer` #: instances replace this attribute with the corresponding HelpMixin #: instance - viewers = OrderedDict([('HTML help', UrlHelp), ('Plain text', TextHelp)]) + viewers = dict([('HTML help', UrlHelp), ('Plain text', TextHelp)]) if not rcParams['help_explorer.use_webengineview']: del viewers['HTML help'] @@ -970,7 +969,7 @@ class HelpExplorer(QWidget, DockMixin): for w in self.viewers.values(): w.setParent(self) else: - self.viewers = OrderedDict( + self.viewers = dict( [(key, cls(parent=self)) for key, cls in six.iteritems( self.viewers)]) # save the UrlHelp because QWebEngineView creates child processes diff --git a/psyplot_gui/main.py b/psyplot_gui/main.py index a7a3722..99206f8 100644 --- a/psyplot_gui/main.py +++ b/psyplot_gui/main.py @@ -39,7 +39,7 @@ from pkg_resources import iter_entry_points from functools import partial from collections import defaultdict, OrderedDict import matplotlib as mpl -from psyplot.compat.pycompat import get_default_value +from psyplot.utils import get_default_value from psyplot_gui import rcParams from threading import Thread import logging @@ -788,7 +788,7 @@ class MainWindow(QMainWindow): pass self.plot_creator = PlotCreator( help_explorer=self.help_explorer, parent=self) - available_width = QDesktopWidget().availableGeometry().width() / 3. + available_width = QDesktopWidget().availableGeometry().width() // 3 width = self.plot_creator.sizeHint().width() height = self.plot_creator.sizeHint().height() # The plot creator window should cover at least one third of the screen diff --git a/psyplot_gui/plot_creator.py b/psyplot_gui/plot_creator.py index 5f62875..eb22dfa 100644 --- a/psyplot_gui/plot_creator.py +++ b/psyplot_gui/plot_creator.py @@ -41,7 +41,6 @@ from itertools import chain, product, cycle, repeat, starmap import matplotlib as mpl import six from psyplot.utils import _temp_bool_prop -from psyplot.compat.pycompat import map, range, filter, OrderedDict from psyplot_gui.compat.qtcompat import ( QWidget, QComboBox, QHBoxLayout, QVBoxLayout, QFileDialog, QToolButton, QIcon, Qt, QListView, QtCore, with_qt5, QAbstractItemView, QPushButton, @@ -592,7 +591,7 @@ class ArrayTable(DragDropTable): """The final dictionary containing the array names necessary for the `arr_names` parameter in the :meth:`psyplot.data.ArrayList.from_dataset` method """ - ret = OrderedDict() + ret = dict() arr_col = self.arr_col for irow in range(self.rowCount()): arr_name = asstring(self.item(irow, arr_col).text()) diff --git a/tests/test_plot_creator.py b/tests/test_plot_creator.py index 40a599f..2bbd917 100644 --- a/tests/test_plot_creator.py +++ b/tests/test_plot_creator.py @@ -6,7 +6,6 @@ import unittest from itertools import chain import _base_testing as bt import psyplot.project as psy -from psyplot.compat.pycompat import range from psyplot_gui.compat.qtcompat import ( QTest, Qt, QStyleOptionViewItem, QWidget, QValidator, QtGui, QtCore, asstring) -- GitLab