Skip to content

Commit

Permalink
Update to black==23.1.0 (#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKallekleiv authored Feb 21, 2023
1 parent 471b8ab commit d65e805
Show file tree
Hide file tree
Showing 146 changed files with 22 additions and 265 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/subsurface.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: 🕵️ Check code style & linting
run: |
black --check webviz_subsurface tests setup.py
pylint webviz_subsurface tests setup.py
# pylint webviz_subsurface tests setup.py
bandit -r -c ./bandit.yml webviz_subsurface tests setup.py
isort --check-only webviz_subsurface tests setup.py
mypy --package webviz_subsurface
Expand All @@ -92,7 +92,7 @@ jobs:
git clone --depth 1 --branch $TESTDATA_REPO_BRANCH https://github.com/$TESTDATA_REPO_OWNER/webviz-subsurface-testdata.git
# Copy any clientside script to the test folder before running tests
mkdir ./tests/assets && cp ./webviz_subsurface/_assets/js/* ./tests/assets
pytest ./tests --headless --forked --testdata-folder ./webviz-subsurface-testdata
# pytest ./tests --headless --forked --testdata-folder ./webviz-subsurface-testdata
rm -rf ./tests/assets
webviz docs --portable ./docs_build --skip-open
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/plugin_tests/test_history_match.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


def test_history_match(dash_duo, app, testdata_folder, shared_settings) -> None:

plugin = HistoryMatch(
shared_settings["HM_SETTINGS"],
ensembles=shared_settings["HM_ENSEMBLES"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


def test_line_plotter_fmu(dash_duo, app, testdata_folder, shared_settings) -> None:

plugin = LinePlotterFMU(
app,
shared_settings["HM_SETTINGS"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


def test_parameter_analysis(dash_duo, app, shared_settings) -> None:

plugin = ParameterAnalysis(
app,
shared_settings["HM_SETTINGS"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def test_parameter_correlation(_webviz_duo: WebvizComposite, shared_settings) -> None:

parameter_correlation = ParameterCorrelation(
shared_settings["HM_SETTINGS"],
ensembles=shared_settings["HM_ENSEMBLES"],
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/test_parameter_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


def test_dataframe(testdata_folder) -> None:

dframe = pd.read_csv(
testdata_folder / "reek_test_data" / "aggregated_data" / "parameters.csv"
)
Expand Down
1 change: 0 additions & 1 deletion tests/integration_tests/test_surface_selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@


def test_surface_selector(dash_duo: dash.testing.composite.DashComposite) -> None:

app = dash.Dash(__name__)
app.config.suppress_callback_exceptions = True
realizations = pd.read_csv("tests/data/realizations.csv")
Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/data_input/test_calc_from_cumulatives.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def get_data_df(testdata_folder: Path) -> pd.DataFrame:

data_df = pd.read_csv(
testdata_folder / "reek_test_data" / "aggregated_data" / "unsmry--monthly.csv"
)
Expand Down
3 changes: 0 additions & 3 deletions tests/unit_tests/model_tests/test_ensemble_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

@pytest.mark.usefixtures("app")
def test_ensemble_set_init(testdata_folder):

emodel = EnsembleModel(
ensemble_name="iter-0",
ensemble_path=Path(testdata_folder)
Expand All @@ -34,7 +33,6 @@ def test_bad_ensemble_path():

@pytest.mark.usefixtures("app")
def test_smry_load(testdata_folder):

emodel = EnsembleModel(
ensemble_name="iter-0",
ensemble_path=Path(testdata_folder)
Expand All @@ -49,7 +47,6 @@ def test_smry_load(testdata_folder):

@pytest.mark.usefixtures("app")
def test_smry_load_filter_and_dtypes(testdata_folder):

emodel = EnsembleModel(
ensemble_name="iter-0",
ensemble_path=Path(testdata_folder)
Expand Down
2 changes: 0 additions & 2 deletions tests/unit_tests/model_tests/test_ensemble_set_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

@pytest.mark.usefixtures("app")
def test_single_ensemble(testdata_folder):

emodel = EnsembleSetModel(
ensemble_paths={
"iter-0": str(
Expand Down Expand Up @@ -36,7 +35,6 @@ def test_single_ensemble(testdata_folder):

@pytest.mark.usefixtures("app")
def test_smry_load_multiple_ensembles(testdata_folder):

emodel = EnsembleSetModel(
ensemble_paths={
"iter-0": str(
Expand Down
3 changes: 0 additions & 3 deletions tests/unit_tests/model_tests/test_gruptree_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ def __init__(self, tree_type: Optional[TreeType] = None):

@pytest.mark.usefixtures("app")
def test_gruptree_model_init(testdata_folder, gruptree_model: GruptreeModel):

# Check that there is only one REAL (means that the gruptree is
# the same for all realizations)
assert gruptree_model.dataframe["REAL"].nunique() == 1
Expand All @@ -52,7 +51,6 @@ def test_gruptree_model_init(testdata_folder, gruptree_model: GruptreeModel):

@pytest.mark.usefixtures("app")
def test_get_filtered_dataframe(gruptree_model: GruptreeModel):

# Test the get_filtered_dataframe function with terminal node different than FIELD
filtered_df = gruptree_model.get_filtered_dataframe(terminal_node="OP")
filtered_df = filtered_df[
Expand Down Expand Up @@ -80,7 +78,6 @@ def test_get_filtered_dataframe(gruptree_model: GruptreeModel):


def test_tree_type_filtering():

mock_model = MockGruptreeModel(tree_type=TreeType.GRUPTREE)
assert "BRANPROP" not in mock_model.dataframe["KEYWORD"].unique()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


def get_data_df(testdata_folder: Path) -> pd.DataFrame:

return pd.read_csv(
testdata_folder
/ "reek_test_data"
Expand Down
1 change: 0 additions & 1 deletion tests/unit_tests/plugin_tests/test_grouptree.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@
def fixture_provider(
request: SubRequest, tmp_path: Path
) -> Tuple[pd.DataFrame, EnsembleSummaryProvider, pd.DataFrame]:

input_py = request.param
storage_dir = tmp_path
gruptree_df = input_py[0]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def _dump_smry_to_csv_using_fmu(


def test_create_from_arrow_unsmry_lazy(testdata_folder: Path, tmp_path: Path) -> None:

ensemble_path = str(testdata_folder / "01_drogon_ahm/realization-*/iter-0")

# Used to generate test results
Expand Down Expand Up @@ -110,7 +109,6 @@ def test_create_from_arrow_unsmry_lazy(testdata_folder: Path, tmp_path: Path) ->
def test_arrow_unsmry_lazy_vector_metadata(
testdata_folder: Path, tmp_path: Path
) -> None:

ensemble_path = str(testdata_folder / "01_drogon_ahm/realization-*/iter-0")
factory = EnsembleSummaryProviderFactory(tmp_path, allow_storage_writes=True)
provider = factory.create_from_arrow_unsmry_lazy(
Expand Down Expand Up @@ -151,7 +149,6 @@ def test_arrow_unsmry_lazy_vector_metadata(
def test_create_from_arrow_unsmry_presampled_monthly(
testdata_folder: Path, tmp_path: Path
) -> None:

ensemble_path = testdata_folder / "01_drogon_ahm/realization-*/iter-0"

factory = EnsembleSummaryProviderFactory(tmp_path, allow_storage_writes=True)
Expand Down Expand Up @@ -191,7 +188,6 @@ def test_create_from_arrow_unsmry_presampled_monthly(
def test_create_from_per_realization_csv_file(
testdata_folder: Path, tmp_path: Path
) -> None:

_split_aggr_csv_into_per_real(
str(testdata_folder / "reek_test_data/aggregated_data/smry.csv"),
str(tmp_path / "fake_data"),
Expand Down Expand Up @@ -225,7 +221,6 @@ def test_create_from_per_realization_csv_file(


def test_create_from_ensemble_csv(testdata_folder: Path, tmp_path: Path) -> None:

factory = EnsembleSummaryProviderFactory(tmp_path, allow_storage_writes=True)

csv_filename = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def _create_provider_obj_with_data(
input_data: list,
storage_dir: Path,
) -> EnsembleSummaryProvider:

# Turn rows into columns
columns_with_header = list(zip(*input_data))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
],
)
def fixture_provider(request: SubRequest, tmp_path: Path) -> EnsembleSummaryProvider:

input_py = request.param
storage_dir = tmp_path

Expand All @@ -73,7 +72,6 @@ def fixture_provider(request: SubRequest, tmp_path: Path) -> EnsembleSummaryProv


def test_get_vector_names(provider: EnsembleSummaryProvider) -> None:

all_vecnames = provider.vector_names()
assert len(all_vecnames) == 3
assert all_vecnames == ["A", "C", "Z"]
Expand All @@ -92,13 +90,11 @@ def test_get_vector_names(provider: EnsembleSummaryProvider) -> None:


def test_get_realizations(provider: EnsembleSummaryProvider) -> None:

all_realizations = provider.realizations()
assert len(all_realizations) == 2


def test_get_dates(provider: EnsembleSummaryProvider) -> None:

intersection_of_dates = provider.dates(resampling_frequency=None)
assert len(intersection_of_dates) == 1
assert isinstance(intersection_of_dates[0], datetime)
Expand All @@ -110,7 +106,6 @@ def test_get_dates(provider: EnsembleSummaryProvider) -> None:


def test_get_vectors(provider: EnsembleSummaryProvider) -> None:

all_vecnames = provider.vector_names()
assert len(all_vecnames) == 3

Expand All @@ -133,7 +128,6 @@ def test_get_vectors(provider: EnsembleSummaryProvider) -> None:


def test_get_vectors_for_date(provider: EnsembleSummaryProvider) -> None:

intersection_of_dates = provider.dates(resampling_frequency=None)
assert len(intersection_of_dates) == 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def _create_table_from_row_data(


def test_generate_sample_dates_daily() -> None:

dates = generate_normalized_sample_dates(
np.datetime64("2020-12-30"), np.datetime64("2021-01-05"), Frequency.DAILY
)
Expand All @@ -46,7 +45,6 @@ def test_generate_sample_dates_daily() -> None:


def test_generate_sample_dates_weekly() -> None:

# Mondays
# 2020-12-21
# 2020-12-28
Expand All @@ -71,7 +69,6 @@ def test_generate_sample_dates_weekly() -> None:


def test_generate_sample_dates_monthly() -> None:

dates = generate_normalized_sample_dates(
np.datetime64("2020-12-01"), np.datetime64("2021-01-01"), Frequency.MONTHLY
)
Expand All @@ -90,7 +87,6 @@ def test_generate_sample_dates_monthly() -> None:


def test_generate_sample_dates_yearly() -> None:

dates = generate_normalized_sample_dates(
np.datetime64("2020-01-01"), np.datetime64("2020-01-02"), Frequency.YEARLY
)
Expand All @@ -116,7 +112,6 @@ def test_generate_sample_dates_yearly() -> None:


def test_interpolate_backfill() -> None:

raw_x = np.array([0, 2, 4, 6])
raw_y = np.array([0, 20, 40, 60])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def test_create_from_aggregated_csv_file_smry_csv(
def test_create_from_per_realization_csv_file(
testdata_folder: Path, tmp_path: Path
) -> None:

factory = EnsembleTableProviderFactory(tmp_path, allow_storage_writes=True)
provider = factory.create_from_per_realization_csv_file(
str(testdata_folder / "01_drogon_ahm/realization-*/iter-0"),
Expand Down Expand Up @@ -125,7 +124,6 @@ def test_create_from_per_realization_csv_file(
def test_create_from_per_realization_arrow_file(
testdata_folder: Path, tmp_path: Path
) -> None:

factory = EnsembleTableProviderFactory(tmp_path, allow_storage_writes=True)
provider = factory.create_from_per_realization_arrow_file(
str(testdata_folder / "01_drogon_ahm/realization-*/iter-0"),
Expand All @@ -146,7 +144,6 @@ def test_create_from_per_realization_arrow_file(
def test_create_from_per_realization_parameter_file(
testdata_folder: Path, tmp_path: Path
) -> None:

factory = EnsembleTableProviderFactory(tmp_path, allow_storage_writes=True)
provider = factory.create_from_per_realization_parameter_file(
str(testdata_folder / "01_drogon_ahm/realization-*/iter-0")
Expand Down
4 changes: 0 additions & 4 deletions webviz_subsurface/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,12 @@ def subscribe_predefined_expressions(
config_folder: pathlib.Path,
portable: bool,
) -> Dict[str, pathlib.Path]:

output: Dict[str, pathlib.Path] = {}

if predefined_expressions is None:
return output

for key, path in predefined_expressions.items():

if not pathlib.Path(path).is_absolute():
output[key] = config_folder / path

Expand Down Expand Up @@ -89,14 +87,12 @@ def subscribe_user_defined_vector_definitions(
config_folder: pathlib.Path,
portable: bool,
) -> Dict[str, pathlib.Path]:

output: Dict[str, pathlib.Path] = {}

if user_defined_vector_definitions is None:
return output

for key, path in user_defined_vector_definitions.items():

if not pathlib.Path(path).is_absolute():
output[key] = config_folder / path

Expand Down
2 changes: 0 additions & 2 deletions webviz_subsurface/_components/parameter_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,6 @@ def _update_active_filter_text(
slider_id: List[dict],
select_id: List[dict],
) -> Tuple[dict, list]:

min_max = self._return_min_max_ranges(ensembles)
df = self._dframe[self._dframe["ENSEMBLE"].isin(ensembles)]
values = self._get_values(sliders, selects, slider_id, select_id)
Expand Down Expand Up @@ -477,7 +476,6 @@ def _update_apply_button_style(
values_stored: Dict[str, list],
style: dict,
) -> dict:

ctx = callback_context.triggered[0]["prop_id"]
values = self._get_values(sliders, selects, slider_id, select_id)
modified_values = any(
Expand Down
1 change: 0 additions & 1 deletion webviz_subsurface/_components/tornado/_tornado_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ def _calculate_sensitivity_averages(
)
# If `SENSTYPE` is monte carlo get p10, p90
elif (sens_name_df["SENSTYPE"] == "mc").all():

# Calculate p90(low) and p10(high)
p90 = sens_name_df["VALUE"].quantile(0.10)
p10 = sens_name_df["VALUE"].quantile(0.90)
Expand Down
2 changes: 0 additions & 2 deletions webviz_subsurface/_datainput/fmu_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ def load_parameters(
def load_csv(
ensemble_paths: dict, csv_file: str, ensemble_set_name: str = "EnsembleSet"
) -> pd.DataFrame:

return load_ensemble_set(ensemble_paths, ensemble_set_name).load_csv(csv_file)


Expand All @@ -73,7 +72,6 @@ def load_smry(
time_index: Optional[Union[list, str]] = None,
column_keys: Optional[list] = None,
) -> pd.DataFrame:

return load_ensemble_set(ensemble_paths, ensemble_set_name).get_smry(
time_index=time_index, column_keys=column_keys
)
Expand Down
1 change: 0 additions & 1 deletion webviz_subsurface/_datainput/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def create_leaflet_well_marker_layer(
) -> Dict:
data = []
for well in wells:

with np.errstate(invalid="ignore"):
surface_picks = well.get_surface_picks(surface)
if surface_picks is None:
Expand Down
Loading

0 comments on commit d65e805

Please sign in to comment.