Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ruff: SLF compliance #1216

Merged
merged 2 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions .ruff.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
extend = "pyproject.toml"

lint.ignore = [
# flake8-self (SLF)
# https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SLF001", # Private member accessed.
]

[lint.extend-per-file-ignores]
"src/geovista/geoplotter.py" = [
# flake8-annotations (ANN)
Expand Down
2 changes: 2 additions & 0 deletions changelog/1216.contributor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Complied with `ruff <https://github.com/astral-sh/ruff>`__
``flake8-self`` (``SLF``) rules. (:user:`bjlittle`)
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ max-statements = 91
# https://docs.astral.sh/ruff/rules/#flake8-annotations-ann
"ANN001", # Missing type annotation for function argument.
"ANN201", # Missing return type annotation for public funciton.
# https://docs.astral.sh/ruff/rules/#flake8-self-slf
"SLF001", # flake8-self: Private member accessed.
]
# TODO @bjlittle: investigate behaviour of commented-out failing test
"tests/core/test_slice_lines.py" = [
Expand Down
6 changes: 3 additions & 3 deletions src/geovista/cache/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@

# maintain the original Pooch.fetch method prior to wrapping
# with user-agent headers version
CACHE._fetch = CACHE.fetch
CACHE._fetch = CACHE.fetch # noqa: SLF001


@wraps(CACHE._fetch)
@wraps(CACHE._fetch) # noqa: SLF001
def _fetch(*args: str, **kwargs: bool | Callable) -> str: # numpydoc ignore=GL08
# default to our http/s downloader with user-agent headers
kwargs.setdefault("downloader", _downloader)
return CACHE._fetch(*args, **kwargs)
return CACHE._fetch(*args, **kwargs) # noqa: SLF001


# override the original Pooch.fetch method with our
Expand Down
6 changes: 3 additions & 3 deletions src/geovista/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ def cast_UnstructuredGrid_to_PolyData( # noqa: N802
raise TypeError(emsg)

# see https://vtk.org/pipermail/vtkusers/2011-March/066506.html
alg = pv._vtk.vtkGeometryFilter()
alg = pv._vtk.vtkGeometryFilter() # noqa: SLF001
alg.AddInputData(mesh)
alg.Update()
result = pv.core.filters._get_output(alg)
result = pv.core.filters._get_output(alg) # noqa: SLF001

if clean:
result = result.clean()
Expand Down Expand Up @@ -898,7 +898,7 @@ def triangulated(surface: pv.PolyData) -> bool:
.. versionadded:: 0.1.0

"""
return np.all(np.diff(surface._offset_array) == 3)
return np.all(np.diff(surface._offset_array) == 3) # noqa: SLF001


def vtk_warnings_off() -> None:
Expand Down
8 changes: 4 additions & 4 deletions src/geovista/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def combine(
common_point_data = set(first.point_data.keys())
common_cell_data = set(first.cell_data.keys())
common_field_data = set(first.field_data.keys())
active_scalars_info = {first.active_scalars_info._namedtuple}
active_scalars_info = {first.active_scalars_info._namedtuple} # noqa: SLF001

for i, mesh in enumerate(meshes):
if not isinstance(mesh, pv.PolyData):
Expand Down Expand Up @@ -404,12 +404,12 @@ def combine(

if n_points:
# compute the number of vertices (N) for each face of the mesh
faces_n = np.diff(mesh._offset_array)
faces_n = np.diff(mesh._offset_array) # noqa: SLF001
# determine the N offset for each face within the faces array
# a face entry consists of (N, v1, v2, ..., vN), where vN is the Nth
# vertex offset (connectivity) for that face into the associated mesh
# points array
faces_n_offset = mesh._offset_array + np.arange(mesh._offset_array.size)
faces_n_offset = mesh._offset_array + np.arange(mesh._offset_array.size) # noqa: SLF001
# offset the current mesh connectivity by the cumulative mesh points count
faces += n_points
# reinstate N for each face entry
Expand All @@ -425,7 +425,7 @@ def combine(
common_cell_data &= set(mesh.cell_data.keys())
common_field_data &= set(mesh.field_data.keys())
if mesh.active_scalars_name:
active_scalars_info &= {mesh.active_scalars_info._namedtuple}
active_scalars_info &= {mesh.active_scalars_info._namedtuple} # noqa: SLF001

points = np.vstack(combined_points)
faces = np.hstack(combined_faces)
Expand Down
4 changes: 2 additions & 2 deletions src/geovista/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def remesh(
poly1.triangulate(inplace=True)

# https://vtk.org/doc/nightly/html/classvtkIntersectionPolyDataFilter.html
alg = pv._vtk.vtkIntersectionPolyDataFilter()
alg = pv._vtk.vtkIntersectionPolyDataFilter() # noqa: SLF001
alg.SetInputDataObject(0, poly0)
alg.SetInputDataObject(1, poly1)
# BoundaryPoints (points) mask array
Expand All @@ -154,7 +154,7 @@ def remesh(
alg.SetSplitSecondOutput(False) # noqa: FBT003
alg.Update()

remeshed: pv.PolyData = pv.core.filters._get_output(alg, oport=1)
remeshed: pv.PolyData = pv.core.filters._get_output(alg, oport=1) # noqa: SLF001

if remeshed.n_cells == 0:
# no remeshing has been performed as the meridian does not intersect the mesh
Expand Down
2 changes: 1 addition & 1 deletion tests/plotting/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
CI: bool = os.environ.get("CI", "false").lower() == "true"

# prepare geovista/pyvista for off-screen image testing
pv.global_theme.load_theme(pv.plotting.themes._TestingTheme())
pv.global_theme.load_theme(pv.plotting.themes._TestingTheme()) # noqa: SLF001
pv.global_theme.window_size = [450, 300]
pv.OFF_SCREEN = True
gv.GEOVISTA_IMAGE_TESTING = True
Expand Down
Loading