Skip to content

Commit

Permalink
Update ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
tkoyama010 committed Dec 26, 2023
1 parent ae215b0 commit 1803601
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 13 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ repos:
hooks:
- id: numpydoc-validation
files: ^src/pvgmsh/

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: ruff
args: [ --fix ]
- id: ruff-format
12 changes: 12 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,15 @@ checks = [
"EX01", # Examples: Will eventually enforce
"YD01", # Yields: No plan to enforce
]

[tool.ruff]
line-length = 100

[tool.ruff.lint]
select = ["ALL"]
ignore = [
"D203",
"D212",
]

[tool.ruff.format]
32 changes: 21 additions & 11 deletions src/pvgmsh/__init__.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
"""PvGmsh package for 3D mesh generation."""
from __future__ import annotations

import tempfile

import gmsh
import numpy as np
import pyvista as pv
import tempfile

from pvgmsh._version import __version__ # noqa: F401
import numpy as np

FRONTAL_DELAUNAY_2D = 6


def frontal_delaunay_2d(edge_source, target_size=None):
"""The Frontal-Delaunay 2D mesh algorithm.
def frontal_delaunay_2d(
edge_source: pv.PolyData,
target_size: float | None,
) -> pv.UnstructuredGrid:
"""
Frontal-Delaunay 2D mesh algorithm.
Parameters
----------
Expand Down Expand Up @@ -67,9 +74,9 @@ def frontal_delaunay_2d(edge_source, target_size=None):

if target_size is None:
target_size = np.max(
np.abs(geometry.bounds[1] - geometry.bounds[0]),
np.abs(geometry.bounds[3] - geometry.bounds[2]),
np.abs(geometry.bounds[5] - geometry.bounds[4]),
np.abs(edge_source.bounds[1] - edge_source.bounds[0]),
np.abs(edge_source.bounds[3] - edge_source.bounds[2]),
np.abs(edge_source.bounds[5] - edge_source.bounds[4]),
)

for i, point in enumerate(edge_source.points):
Expand All @@ -85,7 +92,10 @@ def frontal_delaunay_2d(edge_source, target_size=None):
gmsh.model.mesh.generate(2)

with tempfile.NamedTemporaryFile(
mode="w+", encoding="utf-8", newline="\n", suffix=".msh"
mode="w+",
encoding="utf-8",
newline="\n",
suffix=".msh",
) as fp:
gmsh.write(fp.name)
mesh = pv.read(fp.name)
Expand All @@ -96,8 +106,9 @@ def frontal_delaunay_2d(edge_source, target_size=None):
return mesh


def delaunay_3d():
"""The Delaunay 3D mesh algorithm.
def delaunay_3d() -> pv.UnstructuredGrid:
"""
Delaunay 3D mesh algorithm.
Examples
--------
Expand Down Expand Up @@ -169,4 +180,3 @@ def delaunay_3d():
>>> _ = plotter.add_mesh(mesh, show_edges=True, line_width=4, color="white")
>>> plotter.show(screenshot="delaunay_3d_01.png")
"""
pass
2 changes: 1 addition & 1 deletion src/pvgmsh/__main__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"""The pyvista-gmsh main module for PyVista accessors for Gmsh to generate 3D finite element mesh."""
"""The pyvista-gmsh main module for PyVista accessors for Gmsh."""
3 changes: 2 additions & 1 deletion src/pvgmsh/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Version info for pvgmsh.
"""
Version info for pvgmsh.
On the ``main`` branch, use 'dev0' to denote a development version.
For example:
Expand Down

0 comments on commit 1803601

Please sign in to comment.