Skip to content

Commit

Permalink
STY: Fix linting with latest ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
mferrera committed Dec 9, 2024
1 parent 5e03d78 commit 47ba1bc
Show file tree
Hide file tree
Showing 94 changed files with 131 additions and 46 deletions.
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from datetime import date

import xtgeo
from autoclasstoc import PublicMethods

import xtgeo

version = xtgeo.__version__
release = xtgeo.__version__
project = "xtgeo"
Expand Down
1 change: 1 addition & 0 deletions examples/grid3d_compute_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from os.path import join as ojn

import numpy.ma as npma

import xtgeo

# from memory_profiler import profile
Expand Down
1 change: 1 addition & 0 deletions examples/grid3d_print_init_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import tempfile

import numpy as np

import xtgeo

EXPATH = pathlib.Path("../../xtgeo-testdata/3dgrids/reek")
Expand Down
1 change: 1 addition & 0 deletions examples/regsurf_compute_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from os.path import join as ojn

import numpy.ma as npma

import xtgeo

# from memory_profiler import profile
Expand Down
1 change: 1 addition & 0 deletions examples/wellpath_fence_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from pathlib import Path

import matplotlib.pyplot as plt

import xtgeo

TPATH = Path("../xtgeo-testdata")
Expand Down
12 changes: 5 additions & 7 deletions src/xtgeo/cube/cube1.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def wrapper(cls, *args, **kwargs):
DeprecationWarning,
)
cfile = args[0]
fformat = args[1] if len(args) > 1 else kwargs.get("fformat", None)
fformat = args[1] if len(args) > 1 else kwargs.get("fformat")

mfile = FileWrapper(cfile)
fmt = mfile.fileformat(fformat)
Expand Down Expand Up @@ -1045,9 +1045,8 @@ def scan_segy_traces(sfile: str, outfile: FileLike = None):
oflag = False
# if outfile is none, it means that you want to plot on STDOUT
if outfile is None:
fx = tempfile.NamedTemporaryFile(delete=False, prefix="tmpxgeo")
fx.close()
outfile = fx.name
with tempfile.NamedTemporaryFile(delete=False, prefix="tmpxgeo") as fx:
outfile = fx.name
logger.info("TMP file name is %s", outfile)
oflag = True

Expand Down Expand Up @@ -1082,9 +1081,8 @@ def scan_segy_header(sfile: str, outfile: FileLike = None):
flag = False
# if outfile is none, it means that you want to print on STDOUT
if outfile is None:
fc = tempfile.NamedTemporaryFile(delete=False, prefix="tmpxtgeo")
fc.close()
outfile = fc.name
with tempfile.NamedTemporaryFile(delete=False, prefix="tmpxtgeo") as fc:
outfile = fc.name
logger.info("TMP file name is %s", outfile)
flag = True

Expand Down
2 changes: 1 addition & 1 deletion src/xtgeo/grid3d/grid_property.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def wrapper(self: GridProperty, *args: Any, **kwargs: Any) -> Callable:
"myprop = xtgeo.gridproperty_from_file('some_name.roff') instead",
DeprecationWarning,
)
fformat = kwargs.get("fformat", None)
fformat = kwargs.get("fformat")
mfile = FileWrapper(pfile)
fmt = mfile.fileformat(fformat)

Expand Down
6 changes: 3 additions & 3 deletions src/xtgeo/surface/regular_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,8 @@ def wrapper(cls, *args, **kwargs):
DeprecationWarning,
)
sfile = kwargs.get("sfile", args[0])
fformat = kwargs.get("fformat", None)
values = kwargs.get("values", None)
fformat = kwargs.get("fformat")
values = kwargs.get("values")
if isinstance(values, bool) and values is False:
load_values = False
else:
Expand Down Expand Up @@ -337,7 +337,7 @@ def wrapper(cls, *args, **kwargs):
and kwargs.get("xori", 0.0) == kwargs.get("yori", 0.0) == 0.0
and kwargs.get("xinc", 25.0) == kwargs.get("yinc", 25.0) == 25.0
)
values = kwargs.get("values", None)
values = kwargs.get("values")
if values is None and default:
default_values = [
[1, 6, 11],
Expand Down
4 changes: 2 additions & 2 deletions src/xtgeo/well/blocked_wells.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def from_roxar(self, *args, **kwargs): # pragma: no cover
project = args[0]
gname = args[1]
bwname = args[2]
lognames = kwargs.get("lognames", None)
lognames = kwargs.get("lognames")
ijk = kwargs.get("ijk", True)

_blockedwells_roxapi.import_bwells_roxapi(
Expand Down Expand Up @@ -208,7 +208,7 @@ def _from_roxar(self, *args, **kwargs): # pragma: no cover
project = args[0]
gname = args[1]
bwname = args[2]
lognames = kwargs.get("lognames", None)
lognames = kwargs.get("lognames")
ijk = kwargs.get("ijk", True)

_blockedwells_roxapi.import_bwells_roxapi(
Expand Down
2 changes: 1 addition & 1 deletion src/xtgeo/well/well1.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ def to_roxar(self, *args, **kwargs):
trajectory = kwargs.get("trajectory", "Drilled trajectory")
logrun = kwargs.get("logrun", "log")
realisation = kwargs.get("realisation", 0)
update_option = kwargs.get("update_option", None)
update_option = kwargs.get("update_option")

logger.debug("Not in use: realisation %s", realisation)

Expand Down
2 changes: 1 addition & 1 deletion src/xtgeo/xyz/_xyz_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def to_file(
KeyError if pfilter is set and key(s) are invalid
"""
filter_deprecated = kwargs.get("filter", None)
filter_deprecated = kwargs.get("filter")
if filter_deprecated is not None and pfilter is None:
pfilter = filter_deprecated

Expand Down
2 changes: 1 addition & 1 deletion tests/jupyter/xtgeo1.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"metadata": {},
"outputs": [],
"source": [
"reekfile = '../xtgeo-testdata/3dgrids/reek/REEK.EGRID'\n",
"reekfile = \"../xtgeo-testdata/3dgrids/reek/REEK.EGRID\"\n",
"reekgrid = xtgeo.grid3d.Grid(reekfile)"
]
},
Expand Down
3 changes: 2 additions & 1 deletion tests/test_common/test_calc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import numpy as np
import pytest
from hypothesis import given, strategies as st

import xtgeo
import xtgeo.common.calc as xcalc
from hypothesis import given, strategies as st
from xtgeo import _cxtgeo

xtg = xtgeo.XTGeoDialog()
Expand Down
1 change: 1 addition & 0 deletions tests/test_common/test_cxtgeo_lowlevel.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest

import xtgeo
from xtgeo import _cxtgeo

Expand Down
1 change: 1 addition & 0 deletions tests/test_common/test_sys.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hashlib

import pytest

from xtgeo.common.sys import generic_hash


Expand Down
3 changes: 2 additions & 1 deletion tests/test_cube/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import numpy as np
import pytest
import segyio
import xtgeo
from hypothesis import HealthCheck, given, settings

import xtgeo
from xtgeo.common import XTGeoDialog
from xtgeo.cube import Cube
from xtgeo.cube._cube_import import (
Expand Down
1 change: 1 addition & 0 deletions tests/test_cube/test_cube_deprecations.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

import xtgeo


Expand Down
3 changes: 2 additions & 1 deletion tests/test_cube/test_cube_xtgformats_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
from os.path import join

import pytest
import xtgeo
from numpy.testing import assert_allclose

import xtgeo


@pytest.mark.benchmark(group="import/export")
def test_benchmark_cube_export(benchmark, tmp_path, testdata_path):
Expand Down
1 change: 1 addition & 0 deletions tests/test_etc/test_clib_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest

import xtgeo
from xtgeo import _cxtgeo
from xtgeo.io._file import FileWrapper
Expand Down
1 change: 1 addition & 0 deletions tests/test_etc/test_etc_make_avg_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import numpy as np
import pytest

import xtgeo
from xtgeo.common import XTGeoDialog
from xtgeo.surface import RegularSurface
Expand Down
1 change: 1 addition & 0 deletions tests/test_etc/test_etc_make_hcpv_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import numpy as np
import numpy.ma as ma
import pytest

import xtgeo
from xtgeo.common import XTGeoDialog
from xtgeo.surface import RegularSurface
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/eclrun_fixtures.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from os.path import join

import pytest

import xtgeo


Expand Down
3 changes: 2 additions & 1 deletion tests/test_grid3d/egrid_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import hypothesis.strategies as st
import numpy as np
import xtgeo.grid3d._egrid as xtge
from hypothesis.extra.numpy import arrays

import xtgeo.grid3d._egrid as xtge

from .grdecl_grid_generator import (
coordinate_types,
finites,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_grid3d/grdecl_grid_generator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import hypothesis.strategies as st
import numpy as np
from hypothesis.extra.numpy import arrays

import xtgeo.grid3d._ecl_grid as eclgrid
import xtgeo.grid3d._grdecl_grid as ggrid
from hypothesis.extra.numpy import arrays

from .grid_generator import indices

Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/grid_generator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import hypothesis.strategies as st

import xtgeo

indices = st.integers(min_value=4, max_value=6)
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/gridprop_generator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import hypothesis.strategies as st
import numpy as np
from hypothesis.extra.numpy import arrays

from xtgeo.grid3d import GridProperty

from .grdecl_grid_generator import finites
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_ecl_inte_head.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pytest

from xtgeo.grid3d._ecl_inte_head import InteHead, Phases
from xtgeo.grid3d._ecl_output_file import Simulator, TypeOfGrid, UnitSystem

Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_ecl_logi_head.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import numpy as np

from xtgeo.grid3d._ecl_logi_head import LogiHead
from xtgeo.grid3d._ecl_output_file import Simulator

Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_ecl_simpleb8_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import numpy as np
import pytest
import resfo

import xtgeo

xtg = xtgeo.XTGeoDialog()
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_eclrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import pytest

import xtgeo

from .eclrun_fixtures import * # noqa: F401, F403
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_grdecl_format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from unittest.mock import mock_open, patch

import pytest

from xtgeo.grid3d._grdecl_format import open_grdecl


Expand Down
3 changes: 2 additions & 1 deletion tests/test_grid3d/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import numpy as np
import pytest
import xtgeo
from hypothesis import given

import xtgeo
from xtgeo.common import XTGeoDialog
from xtgeo.grid3d import Grid

Expand Down
3 changes: 2 additions & 1 deletion tests/test_grid3d/test_grid3d_deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@

import numpy as np
import pytest
import xtgeo
from hypothesis import given
from packaging import version

import xtgeo
from xtgeo import GridProperties, GridProperty
from xtgeo.common.version import __version__ as xtgeo_version

Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_grid_bytesio.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io

import numpy as np

import xtgeo


Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_grid_dual_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@

import numpy as np
import pytest

import xtgeo.grid3d.grid


Expand Down
5 changes: 3 additions & 2 deletions tests/test_grid3d/test_grid_ecl_grid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import hypothesis.strategies as st
import numpy as np
import pytest
from hypothesis import HealthCheck, assume, given, settings
from numpy.testing import assert_allclose

import xtgeo
import xtgeo.grid3d._egrid as xtg_egrid
import xtgeo.grid3d._grdecl_grid as ggrid
from hypothesis import HealthCheck, assume, given, settings
from numpy.testing import assert_allclose
from xtgeo.grid3d._ecl_grid import (
inverse_transform_xtgeo_coord_by_mapaxes,
transform_xtgeo_coord_by_mapaxes,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_grid3d/test_grid_egrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import numpy as np
import pytest
import resfo
from hypothesis import HealthCheck, assume, given, settings

import xtgeo as xtg
import xtgeo.grid3d._egrid as xtge
from hypothesis import HealthCheck, assume, given, settings

from .egrid_generator import (
egrids,
Expand Down
1 change: 1 addition & 0 deletions tests/test_grid3d/test_grid_fence.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pathlib

import pytest

import xtgeo

REEKROOT = pathlib.Path("3dgrids/reek/REEK")
Expand Down
3 changes: 2 additions & 1 deletion tests/test_grid3d/test_grid_grdecl.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import hypothesis.strategies as st
import numpy as np
import pytest
from hypothesis import HealthCheck, assume, given, settings

import xtgeo
import xtgeo.grid3d._ecl_grid as ecl_grid
import xtgeo.grid3d._grdecl_grid as ggrid
from hypothesis import HealthCheck, assume, given, settings
from xtgeo.grid3d import Grid
from xtgeo.grid3d._grdecl_format import open_grdecl
from xtgeo.grid3d._grid_import_ecl import grid_from_ecl_grid
Expand Down
Loading

0 comments on commit 47ba1bc

Please sign in to comment.