From 94275c9be83e411288aa1b483a5c025615a221eb Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 12 Jul 2021 09:18:11 -0400 Subject: [PATCH] Drop `_graphics` subpkg; flat is better then nested --- piker/ui/_chart.py | 8 ++++---- piker/ui/{_graphics => }/_cursor.py | 6 +++--- piker/ui/{_graphics => }/_curve.py | 2 +- piker/ui/_editors.py | 2 +- piker/ui/_graphics/__init__.py | 20 -------------------- piker/ui/{_graphics => }/_lines.py | 6 +++--- piker/ui/{_graphics => }/_ohlc.py | 4 ++-- piker/ui/order_mode.py | 2 +- 8 files changed, 15 insertions(+), 35 deletions(-) rename piker/ui/{_graphics => }/_cursor.py (99%) rename piker/ui/{_graphics => }/_curve.py (99%) delete mode 100644 piker/ui/_graphics/__init__.py rename piker/ui/{_graphics => }/_lines.py (99%) rename piker/ui/{_graphics => }/_ohlc.py (99%) diff --git a/piker/ui/_chart.py b/piker/ui/_chart.py index 5a556cb3..41647481 100644 --- a/piker/ui/_chart.py +++ b/piker/ui/_chart.py @@ -40,13 +40,13 @@ from ._axes import ( PriceAxis, YAxisLabel, ) -from ._graphics._cursor import ( +from ._cursor import ( Cursor, ContentsLabel, ) from ._l1 import L1Labels -from ._graphics._ohlc import BarItems -from ._graphics._curve import FastAppendCurve +from ._ohlc import BarItems +from ._curve import FastAppendCurve from ._style import ( hcolor, CHART_MARGINS, @@ -1317,7 +1317,7 @@ async def run_fsp( # graphics.curve.setFillLevel(50) if fsp_func_name == 'rsi': - from ._graphics._lines import level_line + from ._lines import level_line # add moveable over-[sold/bought] lines # and labels only for the 70/30 lines level_line(chart, 20) diff --git a/piker/ui/_graphics/_cursor.py b/piker/ui/_cursor.py similarity index 99% rename from piker/ui/_graphics/_cursor.py rename to piker/ui/_cursor.py index 0ad4fb7a..8a74ffc7 100644 --- a/piker/ui/_graphics/_cursor.py +++ b/piker/ui/_cursor.py @@ -27,13 +27,13 @@ import pyqtgraph as pg from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import QPointF, QRectF -from .._style import ( +from ._style import ( _xaxis_at, hcolor, _font_small, ) -from .._axes import YAxisLabel, XAxisLabel -from ...log import get_logger +from ._axes import YAxisLabel, XAxisLabel +from ..log import get_logger log = get_logger(__name__) diff --git a/piker/ui/_graphics/_curve.py b/piker/ui/_curve.py similarity index 99% rename from piker/ui/_graphics/_curve.py rename to piker/ui/_curve.py index 6214c07c..6b38420a 100644 --- a/piker/ui/_graphics/_curve.py +++ b/piker/ui/_curve.py @@ -23,7 +23,7 @@ from typing import Tuple import pyqtgraph as pg from PyQt5 import QtCore, QtGui, QtWidgets -from ..._profile import pg_profile_enabled +from .._profile import pg_profile_enabled # TODO: got a feeling that dropping this inheritance gets us even more speedups diff --git a/piker/ui/_editors.py b/piker/ui/_editors.py index 00ef362d..b6d17fd9 100644 --- a/piker/ui/_editors.py +++ b/piker/ui/_editors.py @@ -28,7 +28,7 @@ from PyQt5.QtCore import QPointF import numpy as np from ._style import hcolor, _font -from ._graphics._lines import order_line, LevelLine +from ._lines import order_line, LevelLine from ..log import get_logger diff --git a/piker/ui/_graphics/__init__.py b/piker/ui/_graphics/__init__.py deleted file mode 100644 index 2846367a..00000000 --- a/piker/ui/_graphics/__init__.py +++ /dev/null @@ -1,20 +0,0 @@ -# piker: trading gear for hackers -# Copyright (C) 2018-present Tyler Goodlet (in stewardship of piker0) - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. - -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . - -""" -Internal custom graphics mostly built for low latency and reuse. - -""" diff --git a/piker/ui/_graphics/_lines.py b/piker/ui/_lines.py similarity index 99% rename from piker/ui/_graphics/_lines.py rename to piker/ui/_lines.py index 4ff46d8d..2f83ec7f 100644 --- a/piker/ui/_graphics/_lines.py +++ b/piker/ui/_lines.py @@ -26,9 +26,9 @@ from pyqtgraph import Point, functions as fn from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtCore import QPointF -from .._annotate import mk_marker, qgo_draw_markers -from .._label import Label, vbr_left, right_axis -from .._style import hcolor, _font +from ._annotate import mk_marker, qgo_draw_markers +from ._label import Label, vbr_left, right_axis +from ._style import hcolor, _font # TODO: probably worth investigating if we can diff --git a/piker/ui/_graphics/_ohlc.py b/piker/ui/_ohlc.py similarity index 99% rename from piker/ui/_graphics/_ohlc.py rename to piker/ui/_ohlc.py index 24f35075..7ae010fa 100644 --- a/piker/ui/_graphics/_ohlc.py +++ b/piker/ui/_ohlc.py @@ -27,8 +27,8 @@ from PyQt5.QtCore import QLineF, QPointF # from numba import types as ntypes # from ..data._source import numba_ohlc_dtype -from ..._profile import pg_profile_enabled -from .._style import hcolor +from .._profile import pg_profile_enabled +from ._style import hcolor def _mk_lines_array( diff --git a/piker/ui/order_mode.py b/piker/ui/order_mode.py index d57590cf..bb14aaed 100644 --- a/piker/ui/order_mode.py +++ b/piker/ui/order_mode.py @@ -29,7 +29,7 @@ import pyqtgraph as pg from pydantic import BaseModel import trio -from ._graphics._lines import LevelLine, position_line +from ._lines import LevelLine, position_line from ._editors import LineEditor, ArrowEditor from ._window import MultiStatus, main_window from ..clearing._client import open_ems, OrderBook