From 19893b0efabd76c68dfab0133bc157a7bec92ec4 Mon Sep 17 00:00:00 2001 From: Sindre Langeveld Date: Thu, 23 Jan 2025 14:14:14 +0100 Subject: [PATCH] STY: Format with latest ruff --- src/xtgeo/grid3d/_grid_etc1.py | 2 +- src/xtgeo/grid3d/_gridprop_lowlevel.py | 2 +- src/xtgeo/grid3d/grid.py | 4 +--- src/xtgeo/surface/regular_surface.py | 3 +-- src/xtgeo/xyz/_xyz_io.py | 3 +-- src/xtgeo/xyz/points.py | 12 ++++-------- tests/test_grid3d/test_ecl_inte_head.py | 6 +++--- tests/test_grid3d/test_grdecl_format.py | 2 +- tests/test_opm_integration/test_gridprop_io.py | 2 +- 9 files changed, 14 insertions(+), 22 deletions(-) diff --git a/src/xtgeo/grid3d/_grid_etc1.py b/src/xtgeo/grid3d/_grid_etc1.py index 05a33b7d7..a8b7f72f1 100644 --- a/src/xtgeo/grid3d/_grid_etc1.py +++ b/src/xtgeo/grid3d/_grid_etc1.py @@ -964,7 +964,7 @@ def inactivate_inside( ) if ier == 1: - raise RuntimeError("Problems with one or more polygons. " "Not closed?") + raise RuntimeError("Problems with one or more polygons. Not closed?") def collapse_inactive_cells(self: Grid) -> None: diff --git a/src/xtgeo/grid3d/_gridprop_lowlevel.py b/src/xtgeo/grid3d/_gridprop_lowlevel.py index c2d79605d..16b88a3f6 100644 --- a/src/xtgeo/grid3d/_gridprop_lowlevel.py +++ b/src/xtgeo/grid3d/_gridprop_lowlevel.py @@ -162,7 +162,7 @@ def check_shape_ok(self: GridProperty, values: np.ndarray) -> bool: if values.shape == (self._ncol, self._nrow, self._nlay): return True logger.error( - "Wrong shape: Dimens of values %s %s %s" "vs %s %s %s", + "Wrong shape: Dimens of values %s %s %svs %s %s %s", *values.shape, self._ncol, self._nrow, diff --git a/src/xtgeo/grid3d/grid.py b/src/xtgeo/grid3d/grid.py index 25f977f28..9b3b6a10e 100644 --- a/src/xtgeo/grid3d/grid.py +++ b/src/xtgeo/grid3d/grid.py @@ -732,9 +732,7 @@ def props(self) -> list[GridProperty] | None: if isinstance(self._props, GridProperties): return self._props.props if isinstance(self._props, list): - raise RuntimeError( - "self._props is a list, not a GridProperties " "instance" - ) + raise RuntimeError("self._props is a list, not a GridProperties instance") return None @props.setter diff --git a/src/xtgeo/surface/regular_surface.py b/src/xtgeo/surface/regular_surface.py index 85d56a6ee..865e802c0 100644 --- a/src/xtgeo/surface/regular_surface.py +++ b/src/xtgeo/surface/regular_surface.py @@ -315,8 +315,7 @@ def wrapper(cls, *args, **kwargs): # corner cases where we provide some positional arguments # as keyword arguments. _deprecation_msg = ( - "X is a required argument, will no " - "longer be defaulted in xtgeo version 4.0" + "X is a required argument, will no longer be defaulted in xtgeo version 4.0" ) if len(args) != 4: if "ncol" not in kwargs and len(args) != 1: diff --git a/src/xtgeo/xyz/_xyz_io.py b/src/xtgeo/xyz/_xyz_io.py index c8cbea854..5b7333e3a 100644 --- a/src/xtgeo/xyz/_xyz_io.py +++ b/src/xtgeo/xyz/_xyz_io.py @@ -471,8 +471,7 @@ def _from_list_like(plist, zname, attrs, is_polygons) -> pd.DataFrame: attr_first_col = 4 else: raise ValueError( - f"Wrong length detected of row: {totnum}. " - "Are attributes set correct?" + f"Wrong length detected of row: {totnum}. Are attributes set correct?" ) dfr.dropna() dfr = dfr.astype(np.float64) diff --git a/src/xtgeo/xyz/points.py b/src/xtgeo/xyz/points.py index afe7e7a56..50c7007f1 100644 --- a/src/xtgeo/xyz/points.py +++ b/src/xtgeo/xyz/points.py @@ -529,24 +529,20 @@ def _dataframe_consistency_check(self): dataframe = self.get_dataframe(copy=False) if self.xname not in dataframe: raise ValueError( - f"xname={self.xname} is not a column " - f"of dataframe {dataframe.columns}" + f"xname={self.xname} is not a column of dataframe {dataframe.columns}" ) if self.yname not in dataframe: raise ValueError( - f"yname={self.yname} is not a column " - f"of dataframe {dataframe.columns}" + f"yname={self.yname} is not a column of dataframe {dataframe.columns}" ) if self.zname not in dataframe: raise ValueError( - f"zname={self.zname} is not a column " - f"of dataframe {dataframe.columns}" + f"zname={self.zname} is not a column of dataframe {dataframe.columns}" ) for attr in self._attrs: if attr not in dataframe: raise ValueError( - f"Attribute {attr} is not a column " - f"of dataframe {dataframe.columns}" + f"Attribute {attr} is not a column of dataframe {dataframe.columns}" ) def __repr__(self): diff --git a/tests/test_grid3d/test_ecl_inte_head.py b/tests/test_grid3d/test_ecl_inte_head.py index 210866ebb..fc1297212 100644 --- a/tests/test_grid3d/test_ecl_inte_head.py +++ b/tests/test_grid3d/test_ecl_inte_head.py @@ -29,9 +29,9 @@ def test_intehead_iphs_when_e300(): intehead_values = [0] * 100 intehead_values[94] = 300 # simulator is Ecl 300 intehead_values[14] = 8 # 14 is IPHS code in E100 but no. tracers in E300, here 8 - assert ( - InteHead(intehead_values).phases == Phases.OIL_WATER_GAS - ), "phases always OIL_WATER_GAS in Eclipse 300" + assert InteHead(intehead_values).phases == Phases.OIL_WATER_GAS, ( + "phases always OIL_WATER_GAS in Eclipse 300" + ) def test_intehead_iphs_fail_when_outsiderange_e100(): diff --git a/tests/test_grid3d/test_grdecl_format.py b/tests/test_grid3d/test_grdecl_format.py index 008bb1daf..88310cd98 100644 --- a/tests/test_grid3d/test_grdecl_format.py +++ b/tests/test_grid3d/test_grdecl_format.py @@ -88,7 +88,7 @@ def test_read_extra_keyword_characters(): def test_read_long_keyword(): very_long_keyword = "a" * 200 - file_data = f"{very_long_keyword} Eclipse comment\n" "1 2 3 4 /" + file_data = f"{very_long_keyword} Eclipse comment\n1 2 3 4 /" with patch( "builtins.open", mock_open(read_data=file_data), diff --git a/tests/test_opm_integration/test_gridprop_io.py b/tests/test_opm_integration/test_gridprop_io.py index 045103204..5f8ca4ca6 100644 --- a/tests/test_opm_integration/test_gridprop_io.py +++ b/tests/test_opm_integration/test_gridprop_io.py @@ -136,7 +136,7 @@ def deck_contents(self): 0.5 2.0E-6 0.1 0.0 1.0 1.0E-5 0.0 0.0 / PVTW -{self.convert_pressure(270.0)} 1.0 {1.0 / self.convert_pressure(1.0 / 5.0E-5)} 0.3 0.0 / +{self.convert_pressure(270.0)} 1.0 {1.0 / self.convert_pressure(1.0 / 5.0e-5)} 0.3 0.0 / DENSITY {self.convert_density(860.0)} {self.convert_density(1030.0)}