Skip to content

Commit

Permalink
Move plottery into gui/tools/plot
Browse files Browse the repository at this point in the history
  • Loading branch information
eivindjahren committed Oct 7, 2024
1 parent a52cebf commit 1829ad8
Show file tree
Hide file tree
Showing 43 changed files with 117 additions and 84 deletions.
15 changes: 0 additions & 15 deletions src/ert/gui/plottery/__init__.py

This file was deleted.

Empty file.
2 changes: 1 addition & 1 deletion src/ert/gui/simulation/run_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
SnapshotModel,
)
from ert.gui.tools.file import FileDialog
from ert.gui.tools.plot.plot_tool import PlotTool
from ert.gui.tools.plot import PlotTool
from ert.run_models import (
BaseRunModel,
RunModelStatusEvent,
Expand Down
4 changes: 2 additions & 2 deletions src/ert/gui/tools/plot/customize/customization_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
QWidget,
)

from ert.gui.tools.plot.widgets.clearable_line_edit import ClearableLineEdit
from ert.gui.tools.plot.widgets import ClearableLineEdit

from .. import style_chooser as sc

if TYPE_CHECKING:
from ert.gui.plottery import PlotConfig
from ert.gui.tools.plot.plottery import PlotConfig


class CustomizationView(QWidget):
Expand Down
4 changes: 2 additions & 2 deletions src/ert/gui/tools/plot/customize/customize_plot_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
QWidgetAction,
)

from ert.gui.plottery import PlotConfig, PlotConfigFactory, PlotConfigHistory
from ert.gui.tools.plot.plot_api import PlotApiKeyDefinition
from ert.gui.tools.plot.plottery import PlotConfig, PlotConfigFactory, PlotConfigHistory
from ert.gui.tools.plot.widgets import CopyStyleToDialog

from .default_customization_view import DefaultCustomizationView
Expand All @@ -29,7 +29,7 @@
from .style_customization_view import StyleCustomizationView

if TYPE_CHECKING:
from ert.gui.tools.plot.customize import CustomizationView
from .customization_view import CustomizationView


class PlotCustomizer(QObject):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .customization_view import CustomizationView, WidgetProperty

if TYPE_CHECKING:
from ert.gui.plottery import PlotConfig
from ert.gui.tools.plot.plottery import PlotConfig


def _label_msg(label: str) -> str:
Expand Down
8 changes: 3 additions & 5 deletions src/ert/gui/tools/plot/customize/limits_customization_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@
from qtpy.QtGui import QDoubleValidator, QIntValidator
from qtpy.QtWidgets import QLabel, QStackedWidget, QWidget

from ert.gui.plottery import PlotContext
from ert.gui.plottery.plot_limits import PlotLimits
from ert.gui.tools.plot.widgets.clearable_line_edit import ClearableLineEdit
from ert.gui.tools.plot.widgets.custom_date_edit import CustomDateEdit
from ert.gui.tools.plot.plottery import PlotContext, PlotLimits
from ert.gui.tools.plot.widgets import ClearableLineEdit, CustomDateEdit

from .customization_view import CustomizationView

if TYPE_CHECKING:
from ert.gui.plottery import PlotConfig
from ert.gui.tools.plot.plottery import PlotConfig


class StackedInput(QStackedWidget):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .customization_view import CustomizationView, WidgetProperty

if TYPE_CHECKING:
from ert.gui.plottery import PlotConfig
from ert.gui.tools.plot.plottery import PlotConfig


class StatisticsCustomizationView(CustomizationView):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from .customization_view import CustomizationView, WidgetProperty

if TYPE_CHECKING:
from ert.gui.plottery import PlotConfig
from ert.gui.tools.plot.plottery import PlotConfig


class StyleCustomizationView(CustomizationView):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/gui/tools/plot/data_type_keys_list_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from qtpy.QtGui import QColor, QIcon
from typing_extensions import override

from ert.gui.tools.plot.plot_api import PlotApiKeyDefinition
from .plot_api import PlotApiKeyDefinition


class DataTypeKeysListModel(QAbstractItemModel):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/gui/tools/plot/data_type_keys_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
)

from ert.gui.ertwidgets import SearchBox
from ert.gui.tools.plot.plot_api import PlotApiKeyDefinition

from .data_type_keys_list_model import DataTypeKeysListModel
from .data_type_proxy_model import DataTypeProxyModel
from .filter_popup import FilterPopup
from .plot_api import PlotApiKeyDefinition


class _LegendMarker(QWidget):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/gui/tools/plot/filter_popup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
QWidget,
)

from ert.gui.tools.plot.plot_api import PlotApiKeyDefinition
from .plot_api import PlotApiKeyDefinition


class FilterPopup(QDialog):
Expand Down
3 changes: 2 additions & 1 deletion src/ert/gui/tools/plot/filterable_kw_list_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import Dict, List

from ert.gui.ertwidgets.models.selectable_list_model import SelectableListModel
from ert.gui.tools.plot.plot_api import PlotApiKeyDefinition

from .plot_api import PlotApiKeyDefinition


class FilterableKwListModel(SelectableListModel):
Expand Down
2 changes: 1 addition & 1 deletion src/ert/gui/tools/plot/plot_ensemble_selection_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
QWidget,
)

from ert.gui.tools.plot.plot_api import EnsembleObject
from .plot_api import EnsembleObject


class EnsembleSelectionWidget(QWidget):
Expand Down
18 changes: 9 additions & 9 deletions src/ert/gui/tools/plot/plot_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
QWidgetAction,
)

from ert.gui.tools.plot.plot_api import EnsembleObject
from .plot_api import EnsembleObject

if TYPE_CHECKING:
from ert.gui.plottery import PlotContext
from ert.gui.plottery.plots.cesp import CrossEnsembleStatisticsPlot
from ert.gui.plottery.plots.distribution import DistributionPlot
from ert.gui.plottery.plots.ensemble import EnsemblePlot
from ert.gui.plottery.plots.gaussian_kde import GaussianKDEPlot
from ert.gui.plottery.plots.histogram import HistogramPlot
from ert.gui.plottery.plots.statistics import StatisticsPlot
from ert.gui.plottery.plots.std_dev import StdDevPlot
from .plottery import PlotContext
from .plottery.plots.cesp import CrossEnsembleStatisticsPlot
from .plottery.plots.distribution import DistributionPlot
from .plottery.plots.ensemble import EnsemblePlot
from .plottery.plots.gaussian_kde import GaussianKDEPlot
from .plottery.plots.histogram import HistogramPlot
from .plottery.plots.statistics import StatisticsPlot
from .plottery.plots.std_dev import StdDevPlot


class CustomNavigationToolbar(NavigationToolbar2QT):
Expand Down
21 changes: 11 additions & 10 deletions src/ert/gui/tools/plot/plot_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@
from qtpy.QtWidgets import QDockWidget, QMainWindow, QTabWidget, QWidget

from ert.gui.ertwidgets import showWaitCursorWhileWaiting
from ert.gui.plottery import PlotConfig, PlotContext
from ert.gui.plottery.plots.cesp import CrossEnsembleStatisticsPlot
from ert.gui.plottery.plots.distribution import DistributionPlot
from ert.gui.plottery.plots.ensemble import EnsemblePlot
from ert.gui.plottery.plots.gaussian_kde import GaussianKDEPlot
from ert.gui.plottery.plots.histogram import HistogramPlot
from ert.gui.plottery.plots.statistics import StatisticsPlot
from ert.gui.plottery.plots.std_dev import StdDevPlot
from ert.gui.tools.plot.plot_api import EnsembleObject, PlotApiKeyDefinition

from .customize import PlotCustomizer
from .data_type_keys_widget import DataTypeKeysWidget
from .plot_api import PlotApi
from .plot_api import EnsembleObject, PlotApi, PlotApiKeyDefinition
from .plot_ensemble_selection_widget import EnsembleSelectionWidget
from .plot_widget import PlotWidget
from .plottery import PlotConfig, PlotContext
from .plottery.plots import (
CrossEnsembleStatisticsPlot,
DistributionPlot,
EnsemblePlot,
GaussianKDEPlot,
HistogramPlot,
StatisticsPlot,
StdDevPlot,
)

CROSS_ENSEMBLE_STATISTICS = "Cross ensemble statistics"
DISTRIBUTION = "Distribution"
Expand Down
24 changes: 24 additions & 0 deletions src/ert/gui/tools/plot/plottery/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# isort: skip_file

# At least for some combinations of pandas and matplotlib the numpy.datetime64
# dates coming from pandas are not correctly recognized/converted by matplotlib.
# Calling this converter.register() method seems to fix the problem.
from pandas.plotting import register_matplotlib_converters

register_matplotlib_converters()

from .plot_style import PlotStyle
from .plot_limits import PlotLimits
from .plot_config import PlotConfig
from .plot_context import PlotContext
from .plot_config_history import PlotConfigHistory
from .plot_config_factory import PlotConfigFactory

__all__ = [
"PlotConfig",
"PlotConfigFactory",
"PlotConfigHistory",
"PlotContext",
"PlotLimits",
"PlotStyle",
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
from copy import copy
from typing import Any, List, Optional, Tuple

from ert.gui.plottery import PlotLimits, PlotStyle
from .plot_limits import PlotLimits
from .plot_style import PlotStyle


class PlotConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import TYPE_CHECKING

from ert.gui.plottery import PlotConfig
from .plot_config import PlotConfig

if TYPE_CHECKING:
from ert.gui.tools.plot.plot_api import PlotApiKeyDefinition
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from ert.gui.plottery import PlotConfig
from .plot_config import PlotConfig


class PlotConfigHistory:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
if TYPE_CHECKING:
from pandas import DataFrame

from ert.gui.plottery import PlotConfig
from ert.gui.tools.plot.plot_api import EnsembleObject

from .plot_config import PlotConfig


class PlotContext:
UNKNOWN_AXIS = None
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions src/ert/gui/tools/plot/plottery/plots/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from .cesp import CrossEnsembleStatisticsPlot
from .distribution import DistributionPlot
from .ensemble import EnsemblePlot
from .gaussian_kde import GaussianKDEPlot
from .histogram import HistogramPlot
from .statistics import StatisticsPlot
from .std_dev import StdDevPlot

__all__ = [
"CrossEnsembleStatisticsPlot",
"DistributionPlot",
"EnsemblePlot",
"GaussianKDEPlot",
"HistogramPlot",
"StatisticsPlot",
"StdDevPlot",
]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from matplotlib.figure import Figure
from pandas import DataFrame

from ert.gui.plottery import PlotConfig, PlotContext
from ert.gui.tools.plot.plottery import PlotConfig, PlotContext


CcsData = TypedDict(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from ert.gui.plottery import PlotConfig, PlotContext
from ert.gui.tools.plot.plottery import PlotConfig, PlotContext


class DistributionPlot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import numpy as np
import pandas as pd

from ert.gui.plottery.plots.history import plotHistory
from ert.summary_key_type import is_rate

from .history import plotHistory
from .observations import plotObservations
from .plot_tools import PlotTools

Expand All @@ -16,8 +16,8 @@
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from ert.gui.plottery import PlotConfig, PlotContext
from ert.gui.tools.plot.plot_api import EnsembleObject
from ert.gui.tools.plot.plottery import PlotConfig, PlotContext


class EnsemblePlot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from ert.gui.plottery import PlotConfig, PlotContext
from ert.gui.tools.plot.plottery import PlotConfig, PlotContext


class GaussianKDEPlot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from ert.gui.plottery import PlotContext, PlotStyle
from ert.gui.tools.plot.plottery import PlotContext, PlotStyle


class HistogramPlot:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if TYPE_CHECKING:
from matplotlib.axes import Axes

from ert.gui.plottery import PlotContext
from ert.gui.tools.plot.plottery import PlotContext


def plotHistory(plot_context: "PlotContext", axes: "Axes") -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from matplotlib.axes import Axes
from pandas import DataFrame

from ert.gui.plottery import PlotConfig, PlotContext
from ert.gui.tools.plot.plottery import PlotConfig, PlotContext


def plotObservations(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from matplotlib.axes import Axes
from matplotlib.figure import Figure

from ert.gui.plottery import PlotContext
from ert.gui.tools.plot.plottery import PlotContext


class PlotTools:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
from matplotlib.patches import Rectangle
from pandas import DataFrame

from ert.gui.plottery import PlotConfig, PlotContext, PlotStyle
from ert.gui.plottery.plots.history import plotHistory
from ert.gui.tools.plot.plottery import PlotConfig, PlotContext, PlotStyle

from .history import plotHistory
from .observations import plotObservations
from .plot_tools import PlotTools

Expand Down
Loading

0 comments on commit 1829ad8

Please sign in to comment.