From 3edaec833e99c3958e8ac70483c6617c0afa82d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Lind-Johansen?= Date: Mon, 15 May 2023 10:45:01 +0200 Subject: [PATCH] Fixed pylint issue --- .../_utils/__init__.py | 2 + ...mulation_time_series_onebyone_datamodel.py | 49 ++++++++++--------- .../_views/_onebyone_view/_view.py | 10 ++-- 3 files changed, 32 insertions(+), 29 deletions(-) diff --git a/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/__init__.py b/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/__init__.py index 09f7d4867..19168c7b2 100644 --- a/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/__init__.py +++ b/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/__init__.py @@ -1,5 +1,7 @@ from ._datetime_utils import date_from_str, date_to_str from ._simulation_time_series_onebyone_datamodel import ( SimulationTimeSeriesOneByOneDataModel, + create_tornado_table, create_vector_selector_data, + get_tornado_data, ) diff --git a/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/_simulation_time_series_onebyone_datamodel.py b/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/_simulation_time_series_onebyone_datamodel.py index 965107c78..f22792005 100644 --- a/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/_simulation_time_series_onebyone_datamodel.py +++ b/webviz_subsurface/plugins/_simulation_time_series_onebyone/_utils/_simulation_time_series_onebyone_datamodel.py @@ -150,18 +150,6 @@ def get_tornado_reference(sensitivities: List[str], existing_reference: str) -> return "rms_seed" return sensitivities[0] - def get_tornado_data( - self, dframe: pd.DataFrame, response: str, selections: dict - ) -> TornadoData: - dframe.rename(columns={response: "VALUE"}, inplace=True) - return TornadoData( - dframe=dframe, - reference=selections["Reference"], - response_name=response, - scale=selections["Scale"], - cutbyref=bool(selections["Remove no impact"]), - ) - def create_tornado_figure( self, tornado_data: TornadoData, @@ -224,18 +212,6 @@ def create_realplot(self, tornado_data: TornadoData) -> go.Figure: ) ) - def create_tornado_table( - self, - tornado_data: TornadoData, - use_si_format: bool, - ) -> Tuple[List[dict], List[dict]]: - tornado_table = TornadoTable( - tornado_data=tornado_data, - use_si_format=use_si_format, - precision=4 if use_si_format else 3, - ) - return tornado_table.as_plotly_table, tornado_table.columns - def create_timeseries_figure( self, dframe: pd.DataFrame, @@ -262,6 +238,31 @@ def create_timeseries_figure( ).update_layout({"title": f"{vector}"}) +def get_tornado_data( + dframe: pd.DataFrame, response: str, selections: dict +) -> TornadoData: + dframe.rename(columns={response: "VALUE"}, inplace=True) + return TornadoData( + dframe=dframe, + reference=selections["Reference"], + response_name=response, + scale=selections["Scale"], + cutbyref=bool(selections["Remove no impact"]), + ) + + +def create_tornado_table( + tornado_data: TornadoData, + use_si_format: bool, +) -> Tuple[List[dict], List[dict]]: + tornado_table = TornadoTable( + tornado_data=tornado_data, + use_si_format=use_si_format, + precision=4 if use_si_format else 3, + ) + return tornado_table.as_plotly_table, tornado_table.columns + + def create_vector_selector_data(vector_names: list) -> list: vector_selector_data: list = [] for vector in _get_non_historical_vector_names(vector_names): diff --git a/webviz_subsurface/plugins/_simulation_time_series_onebyone/_views/_onebyone_view/_view.py b/webviz_subsurface/plugins/_simulation_time_series_onebyone/_views/_onebyone_view/_view.py index 555bd3ad6..43e7eea72 100644 --- a/webviz_subsurface/plugins/_simulation_time_series_onebyone/_views/_onebyone_view/_view.py +++ b/webviz_subsurface/plugins/_simulation_time_series_onebyone/_views/_onebyone_view/_view.py @@ -12,9 +12,11 @@ from ..._types import LineType from ..._utils import ( SimulationTimeSeriesOneByOneDataModel, + create_tornado_table, create_vector_selector_data, date_from_str, date_to_str, + get_tornado_data, ) from ._settings import GeneralSettings, Selections, SensitivityFilter, Visualization from ._view_elements import BottomVisualizationViewElement, GeneralViewElement @@ -496,7 +498,7 @@ def _update_tornadoplot( ), ) - tornado_data = self._data_model.get_tornado_data(data, vector, selections) + tornado_data = get_tornado_data(data, vector, selections) use_si_format = tornado_data.reference_average > 1000 tornadofig = self._data_model.create_tornado_figure( tornado_data=tornado_data, @@ -504,9 +506,7 @@ def _update_tornadoplot( use_si_format=use_si_format, title=f"Tornadoplot for {tornado_data.response_name} at {date}
", ) - table, columns = self._data_model.create_tornado_table( - tornado_data, use_si_format - ) + table, columns = create_tornado_table(tornado_data, use_si_format) return table, columns, tornadofig @callback( @@ -570,7 +570,7 @@ def _update_realplot( ensemble ), ) - tornado_data = self._data_model.get_tornado_data(data, vector, selections) + tornado_data = get_tornado_data(data, vector, selections) return self._data_model.create_realplot(tornado_data)