diff --git a/src/xtgeo/common/calc.py b/src/xtgeo/common/calc.py index e2c2e1af1..edc698c1a 100644 --- a/src/xtgeo/common/calc.py +++ b/src/xtgeo/common/calc.py @@ -286,10 +286,7 @@ def point_in_tetrahedron( status = _cxtgeo.x_point_in_tetrahedron(x0, y0, z0, vertices) if status == 1: raise XTGeoCLibError("Error in x_point_in_tetrahedron") - if status == 100: - return True - - return False + return status == 100 def point_in_hexahedron( diff --git a/src/xtgeo/grid3d/_roff_parameter.py b/src/xtgeo/grid3d/_roff_parameter.py index bb4ec7053..fb6e5f23d 100644 --- a/src/xtgeo/grid3d/_roff_parameter.py +++ b/src/xtgeo/grid3d/_roff_parameter.py @@ -216,9 +216,7 @@ def from_file(filelike: FileLike, name: str | None = None) -> RoffParameter: def should_skip_parameter(tag: str, key: str) -> bool: if tag == "parameter" and key[0] == "name": - if name is None or key[1] == name: - return False - return True + return not (name is None or key[1] == name) return False translate_kws = { diff --git a/src/xtgeo/grid3d/grid_properties.py b/src/xtgeo/grid3d/grid_properties.py index d29f7f5c2..41e7548fb 100644 --- a/src/xtgeo/grid3d/grid_properties.py +++ b/src/xtgeo/grid3d/grid_properties.py @@ -395,11 +395,7 @@ def __str__(self) -> str: def __contains__(self, name: str) -> bool: """bool: Emulate 'if "PORO" in props'.""" - prop = self.get_prop_by_name(name, raiseserror=False) - if prop: - return True - - return False + return bool(self.get_prop_by_name(name, raiseserror=False)) def __getitem__(self, name: str) -> GridProperty: # noqa: D105 prop = self.get_prop_by_name(name, raiseserror=False) diff --git a/src/xtgeo/surface/_zmap_parser.py b/src/xtgeo/surface/_zmap_parser.py index ee19d33a5..180e0e814 100644 --- a/src/xtgeo/surface/_zmap_parser.py +++ b/src/xtgeo/surface/_zmap_parser.py @@ -105,9 +105,7 @@ def parse_header(zmap_data): def is_comment(line): - if line.startswith(("!", "+")): - return True - return False + return line.startswith(("!", "+")) def parse_values(zmap_data, nan_value): diff --git a/src/xtgeo/well/well1.py b/src/xtgeo/well/well1.py index 1ae319658..957b534c0 100644 --- a/src/xtgeo/well/well1.py +++ b/src/xtgeo/well/well1.py @@ -845,12 +845,10 @@ def isdiscrete(self, logname): .. versionadded:: 2.2.0 """ - if ( + return ( logname in self.get_lognames() and self.get_logtype(logname) == _AttrType.DISC.value - ): - return True - return False + ) def copy(self): """Copy a Well instance to a new unique Well instance.""" @@ -1132,10 +1130,7 @@ def may_overlap(self, other): if xmin1 > xmax2 or ymin1 > ymax2: return False - if xmin2 > xmax1 or ymin2 > ymax1: - return False - - return True + return not (xmin2 > xmax1 or ymin2 > ymax1) def limit_tvd(self, tvdmin, tvdmax): """Truncate the part of the well that is outside tvdmin, tvdmax. diff --git a/tests/conftest.py b/tests/conftest.py index 3fa284101..fc90e3938 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -89,9 +89,7 @@ def fixture_xtgshow(): """For eventual plotting, to be uses in an if sence inside a test.""" if "ROXENV" in os.environ: pytest.skip("Skip plotting tests in roxar environment") - if any(word in os.environ for word in ["XTGSHOW", "XTG_SHOW"]): - return True - return False + return any(word in os.environ for word in ["XTGSHOW", "XTG_SHOW"]) @pytest.fixture(name="generate_plot") diff --git a/tests/test_cube/test_cube.py b/tests/test_cube/test_cube.py index 04870bf2b..c1ad567b3 100644 --- a/tests/test_cube/test_cube.py +++ b/tests/test_cube/test_cube.py @@ -12,7 +12,6 @@ _import_segy_all_traces, _import_segy_incomplete_traces, ) -from xtgeo.io._file import FileWrapper xtg = XTGeoDialog() logger = xtg.basiclogger(__name__) @@ -214,13 +213,12 @@ def test_internal_segy_import_full_vs_partial(testdata_path): Most prominent, a full SEGY cube should be possible to parse using the same routine as used for cubes with missing traces. """ - segyfile = FileWrapper(testdata_path / SFILE5) - with segyio.open(testdata_path / SFILE5, "r") as segyfile: - attrs1 = _import_segy_all_traces(segyfile) + with segyio.open(testdata_path / SFILE5, "r") as f: + attrs1 = _import_segy_all_traces(f) - with segyio.open(testdata_path / SFILE5, "r") as segyfile: - attrs2 = _import_segy_incomplete_traces(segyfile) + with segyio.open(testdata_path / SFILE5, "r") as f: + attrs2 = _import_segy_incomplete_traces(f) for key, val in attrs1.items(): if isinstance(val, np.ndarray): diff --git a/tests/test_well/test_well.py b/tests/test_well/test_well.py index 1b80d0776..543c58f28 100644 --- a/tests/test_well/test_well.py +++ b/tests/test_well/test_well.py @@ -101,7 +101,7 @@ def test_import(loadwell1, snapshot, helpers): "loadwell1.csv", ) - assert { + assert expected_result == { "well_name": mywell.wellname, "xpos": mywell.xpos, "wpos": mywell.ypos, @@ -112,7 +112,7 @@ def test_import(loadwell1, snapshot, helpers): "nlogs": mywell.nlogs, "lognames": mywell.lognames, "lognames_all": mywell.lognames_all, - } == expected_result + } def test_import_long_well(loadwell3): diff --git a/tests/test_well/test_well_to_points.py b/tests/test_well/test_well_to_points.py index 1383ddddd..eacb52e52 100644 --- a/tests/test_well/test_well_to_points.py +++ b/tests/test_well/test_well_to_points.py @@ -158,10 +158,10 @@ def test_simple_points(well_spec, expected_result, string_to_well, zonelist, use kwargs = {"zonelogname": "Zonelog"} well = string_to_well(well_spec, **kwargs) points = well.get_zonation_points(use_undef=use_undef, tops=True, zonelist=zonelist) - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + } def test_simple_points_two(string_to_well): @@ -181,16 +181,16 @@ def test_simple_points_two(string_to_well): well = string_to_well(wellstring, **kwargs) points = well.get_zonation_points(use_undef=False, tops=True, zonelist=[1, 2, 3]) expected_result = {"X_UTME": [7.0, 13.0], "Y_UTMN": [8.0, 14.0]} - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + } assert len(points) == 2 points = well.get_zonation_points(use_undef=False, tops=True, zonelist=[2, 3]) - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + } assert len(points) == 2 @@ -214,10 +214,10 @@ def test_break_zonation(string_to_well): "X_UTME": [4.0, 4.0, 10.0, 13.0], "Y_UTMN": [5.0, 5.0, 11.0, 14.0], } - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + } @pytest.mark.parametrize( @@ -273,10 +273,10 @@ def test_tops_value(string_to_well, tops_flag, expected_result): kwargs = {"zonelogname": "Zonelog"} well = string_to_well(wellstring, **kwargs) points = well.get_zonation_points(use_undef=False, tops=tops_flag, zonelist=[2, 3]) - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + } @pytest.mark.parametrize( @@ -308,10 +308,10 @@ def test_include_limit(string_to_well, include_limit, expected_result): points = well.get_zonation_points( use_undef=False, tops=False, zonelist=(1, 5), incl_limit=include_limit ) - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + } @pytest.mark.parametrize( @@ -371,7 +371,7 @@ def test_zonelist(string_to_well, zone_list, expected_result): tops=True, zonelist=zone_list, ) - assert { + assert expected_result == { "X_UTME": points["X_UTME"].to_list(), "Y_UTMN": points["Y_UTMN"].to_list(), - } == expected_result + }