Skip to content

Commit

Permalink
Pylint changes related to webviz-config (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kallekleiv authored Oct 2, 2019
1 parent 4914d92 commit 332fde5
Show file tree
Hide file tree
Showing 20 changed files with 74 additions and 107 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"scipy~=1.2",
"dash-daq~=0.1",
"matplotlib~=3.0",
"webviz-config>=0.0.4",
"webviz-config>=0.0.23",
"webviz-subsurface-components>=0.0.3",
"pillow~=6.1",
"xtgeo~=2.1",
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/test_inplace_volumes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mock
import dash
import pandas as pd
from webviz_config.common_cache import cache
from webviz_config.common_cache import CACHE
from webviz_config.containers import InplaceVolumes

# mocked functions
Expand All @@ -14,7 +14,7 @@ def test_inplace_volumes(dash_duo):
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.config.suppress_callback_exceptions = True
cache.init_app(app.server)
CACHE.init_app(app.server)
container_settings = {"scratch_ensembles": {"iter-0": "", "iter-1": ""}}
ensembles = ["iter-0", "iter-1"]
volfiles = {"geogrid": "geogrid--oil.csv", "simgrid": "simgrid--oil.csv"}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration_tests/test_parameter_corr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mock
import dash
import pandas as pd
from webviz_config.common_cache import cache
from webviz_config.common_cache import CACHE
from webviz_config.containers import ParameterCorrelation

# mocked functions
Expand All @@ -14,7 +14,7 @@ def test_parameter_corr(dash_duo):
app.css.config.serve_locally = True
app.scripts.config.serve_locally = True
app.config.suppress_callback_exceptions = True
cache.init_app(app.server)
CACHE.init_app(app.server)
container_settings = {"scratch_ensembles": {"iter-0": ""}}
ensembles = ["iter-0"]

Expand Down
33 changes: 0 additions & 33 deletions tests/test_parameter_correlation.py

This file was deleted.

8 changes: 4 additions & 4 deletions webviz_subsurface/containers/_disk_usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import webviz_core_components as wcc
from dash.dependencies import Input, Output
from webviz_config.webviz_store import webvizstore
from webviz_config.common_cache import cache
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import CACHE
from webviz_config import WebvizContainerABC


class DiskUsage(WebvizContainer):
class DiskUsage(WebvizContainerABC):
"""### Disk usage
This container adds functionality for standard visualization of disk usage in
Expand Down Expand Up @@ -99,7 +99,7 @@ def add_webvizstore(self):
return [(get_disk_usage, [{"scratch_dir": self.scratch_dir}])]


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
@webvizstore
def get_disk_usage(scratch_dir) -> pd.DataFrame:
try:
Expand Down
4 changes: 2 additions & 2 deletions webviz_subsurface/containers/_history_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from scipy.stats import chi2
import dash_html_components as html
import webviz_subsurface_components as wsc
from webviz_config.containers import WebvizContainer
from webviz_config import WebvizContainerABC

from ..datainput import extract_mismatch


class HistoryMatch(WebvizContainer):
class HistoryMatch(WebvizContainerABC):
"""### History match
This container visualizes the quality of the history match.
Expand Down
12 changes: 6 additions & 6 deletions webviz_subsurface/containers/_inplace_volumes.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import dash_core_components as dcc
import webviz_core_components as wcc
from dash.dependencies import Input, Output
from webviz_config.common_cache import cache
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import CACHE
from webviz_config import WebvizContainerABC

from ..datainput import extract_volumes


class InplaceVolumes(WebvizContainer):
class InplaceVolumes(WebvizContainerABC):
"""### Volumetrics
This container visualizes inplace volumetrics results from
Expand Down Expand Up @@ -350,7 +350,7 @@ def _set_source_selector(group_by):
return False, list(self.volumes["SOURCE"].unique())[0]


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def plot_data(plot_type, dframe, response, name):
values = dframe[response]

Expand Down Expand Up @@ -383,7 +383,7 @@ def plot_data(plot_type, dframe, response, name):
return output


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def plot_layout(plot_type, response):

if plot_type == "Histogram":
Expand All @@ -406,7 +406,7 @@ def plot_layout(plot_type, response):
return output


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def filter_dataframe(dframe, columns, column_values):
df = dframe.copy()
if not isinstance(columns, list):
Expand Down
8 changes: 4 additions & 4 deletions webviz_subsurface/containers/_inplace_volumes_onebyone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@

import webviz_core_components as wcc
from dash.dependencies import Input, Output, State
from webviz_config.common_cache import cache
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import CACHE
from webviz_config import WebvizContainerABC
from webviz_subsurface.private_containers._tornado_plot import TornadoPlot

from ..datainput import extract_volumes, get_realizations


class InplaceVolumesOneByOne(WebvizContainer):
class InplaceVolumesOneByOne(WebvizContainerABC):
# pylint: disable=too-many-instance-attributes
"""### InplaceVolumesOneByOne
Expand Down Expand Up @@ -462,7 +462,7 @@ def calculate_table_rows(df, response):
return table


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def filter_dataframe(dframe, columns, column_values):
df = dframe.copy()
if not isinstance(columns, list):
Expand Down
14 changes: 7 additions & 7 deletions webviz_subsurface/containers/_intersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
import webviz_core_components as wcc
from dash.dependencies import Input, Output, State
from dash_table import DataTable
from webviz_config.common_cache import cache
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import CACHE
from webviz_config import WebvizContainerABC

from ..datainput import scratch_ensemble, load_surface, get_wfence, get_hfence


class Intersect(WebvizContainer):
class Intersect(WebvizContainerABC):
"""### Intersect
This container visualizes surfaces intersected along a well path.
Expand Down Expand Up @@ -107,7 +107,7 @@ def surface_colors(self):
for i, surf in enumerate(self.surface_names)
}

# @cache.memoize(timeout=cache.TIMEOUT)
# @CACHE.memoize(timeout=CACHE.TIMEOUT)
# def agg_surfaces(self, surf_names, calc='avg'):
# agg = []
# for s_name in surf_names:
Expand All @@ -118,7 +118,7 @@ def surface_colors(self):
# agg.append(s)
# return agg

@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def plot_xsection(self, well, reals, surf_names, tvdmin=0):
"""Plots all lines in intersection"""
traces = []
Expand Down Expand Up @@ -328,7 +328,7 @@ def _hover(_data, _fig, _surfaces):
]


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def make_well_trace(well, tvdmin=0):
"""Creates well trace for graph"""
x = [trace[3] for trace in get_wfence(well, extend=2).values]
Expand All @@ -348,7 +348,7 @@ def make_well_trace(well, tvdmin=0):
}


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def make_surface_traces(well, reals, surf_name, cat, color):
"""Creates surface traces for graph"""
plot_data = []
Expand Down
8 changes: 4 additions & 4 deletions webviz_subsurface/containers/_morris_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from dash.dependencies import Input, Output
from webviz_subsurface_components import Morris
from webviz_config.webviz_store import webvizstore
from webviz_config.common_cache import cache
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import CACHE
from webviz_config import WebvizContainerABC


class MorrisPlot(WebvizContainer):
class MorrisPlot(WebvizContainerABC):
"""### Morris
This container renders a visualization of the Morris sampling method.
Expand Down Expand Up @@ -82,7 +82,7 @@ def _update_plot(vector):
return output, vector, parameters


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
@webvizstore
def read_csv(csv_file) -> pd.DataFrame:
return pd.read_csv(csv_file)
14 changes: 7 additions & 7 deletions webviz_subsurface/containers/_parameter_correlation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import webviz_core_components as wcc
from dash.dependencies import Input, Output
from webviz_config.webviz_store import webvizstore
from webviz_config.common_cache import cache
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import CACHE
from webviz_config import WebvizContainerABC

from ..datainput import scratch_ensemble

Expand All @@ -24,7 +24,7 @@ def dropdown_from_dict(dom_id, dictionary):
)


class ParameterCorrelation(WebvizContainer):
class ParameterCorrelation(WebvizContainerABC):
"""### Parameter correlation
This container shows parameter correlation using a correlation matrix,
Expand Down Expand Up @@ -249,14 +249,14 @@ def add_webvizstore(self):
]


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
@webvizstore
def get_parameters(ensemble_path) -> pd.DataFrame:

return scratch_ensemble("", ensemble_path).parameters


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def render_scatter(ens1, x_col, ens2, y_col, color, density):
if ens1 == ens2:
real_text = [f"Realization:{r}" for r in get_parameters(ens1)["REAL"]]
Expand Down Expand Up @@ -365,7 +365,7 @@ def render_scatter(ens1, x_col, ens2, y_col, color, density):
return {"data": data, "layout": layout}


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def get_corr_data(ensemble_path, drop_constants=True):
"""
if drop_constants:
Expand All @@ -390,7 +390,7 @@ def get_corr_data(ensemble_path, drop_constants=True):
)


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def render_matrix(ensemble_path, drop_constants=True):
corr_data = get_corr_data(ensemble_path, drop_constants)

Expand Down
4 changes: 2 additions & 2 deletions webviz_subsurface/containers/_parameter_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
import webviz_core_components as wcc
from dash.exceptions import PreventUpdate
from dash.dependencies import Input, Output, State
from webviz_config.containers import WebvizContainer
from webviz_config import WebvizContainerABC

from ..datainput import load_parameters


class ParameterDistribution(WebvizContainer):
class ParameterDistribution(WebvizContainerABC):
"""### ParameterDistribution
This container shows parameter distribution per ensemble as a histogram
Expand Down
12 changes: 6 additions & 6 deletions webviz_subsurface/containers/_reservoir_simulation_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
from dash.dependencies import Input, Output, State
from plotly.colors import DEFAULT_PLOTLY_COLORS
import plotly.graph_objs as go
from webviz_config.containers import WebvizContainer
from webviz_config.common_cache import cache
from webviz_config import WebvizContainerABC
from webviz_config.common_cache import CACHE

from ..datainput import (
get_time_series_data,
Expand All @@ -26,7 +26,7 @@
# =============================================================================


class ReservoirSimulationTimeSeries(WebvizContainer):
class ReservoirSimulationTimeSeries(WebvizContainerABC):
"""### Time series from reservoir simulations
* `ensembles`: Which ensembles in `container_settings` to visualize.
Expand Down Expand Up @@ -363,7 +363,7 @@ def _user_download_data(
).filter(items=["STATISTIC", vector, "DATE", "ENSEMBLE"])

return (
WebvizContainer.container_data_compress(
WebvizContainerABC.container_data_compress(
[
{
"filename": f"{file_name}.csv",
Expand Down Expand Up @@ -436,7 +436,7 @@ def add_webvizstore(self):
# =============================================================================


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def render_realization_plot(
ensemble_paths: tuple,
time_index: str,
Expand Down Expand Up @@ -552,7 +552,7 @@ def render_realization_plot(
return wcc.Graph(figure={"data": plot_traces, "layout": layout})


@cache.memoize(timeout=cache.TIMEOUT)
@CACHE.memoize(timeout=CACHE.TIMEOUT)
def render_stat_plot(
ensemble_paths: tuple,
time_index: str,
Expand Down
Loading

0 comments on commit 332fde5

Please sign in to comment.