Skip to content

Commit

Permalink
Fixed pylint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Øyvind Lind-Johansen committed May 15, 2023
1 parent 9bf2bcf commit 3edaec8
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -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,
)
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -496,17 +498,15 @@ 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,
selections=selections,
use_si_format=use_si_format,
title=f"Tornadoplot for {tornado_data.response_name} at {date} <br>",
)
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(
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 3edaec8

Please sign in to comment.