From 71b7087019d9f651974f7ad52d38818ab41860d4 Mon Sep 17 00:00:00 2001 From: Tetsuo Koyama Date: Fri, 29 Dec 2023 15:06:08 +0900 Subject: [PATCH] Dropping black and use ruff as formatter (#31) --- .pre-commit-config.yaml | 16 +++++++--------- README.rst | 6 ++++++ src/pvgmsh/__init__.py | 22 ++++++++-------------- 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4757aa03..c1a63b05 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -2,15 +2,6 @@ ci: autofix_prs: true autoupdate_schedule: weekly repos: -- repo: https://github.com/psf/black - rev: 23.12.1 - hooks: - - id: black -- repo: https://github.com/keewis/blackdoc - rev: v0.3.9 - hooks: - - id: blackdoc - files: '\.py$' - repo: https://github.com/DanielNoord/pydocstringformatter rev: v0.7.3 @@ -27,3 +18,10 @@ repos: hooks: - id: numpydoc-validation files: ^src/pvgmsh/ + +- repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.1.9 + hooks: + - id: ruff + args: [ --fix ] + - id: ruff-format diff --git a/README.rst b/README.rst index 5b9fe9c6..194aa671 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,9 @@ +.. |Ruff| image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json + :target: https://github.com/astral-sh/ruff + :alt: Ruff + +|Ruff| + Motivation ========== diff --git a/src/pvgmsh/__init__.py b/src/pvgmsh/__init__.py index dbba248f..377492ae 100644 --- a/src/pvgmsh/__init__.py +++ b/src/pvgmsh/__init__.py @@ -81,21 +81,15 @@ def frontal_delaunay_2d(edge_source, target_size=None): gmsh.initialize() gmsh.option.set_number("Mesh.Algorithm", 6) + if target_size is None: + target_size = np.max( + 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): - if target_size is None: - gmsh.model.geo.add_point( - point[0], - point[1], - point[2], - 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]), - ), - i + 1, - ) - else: - gmsh.model.geo.add_point(point[0], point[1], point[2], target_size, i + 1) + gmsh.model.geo.add_point(point[0], point[1], point[2], target_size, i + 1) lines = edge_source.lines for i in range(lines[0] - 1):