diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c43f624..2be6680 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,22 +3,22 @@ name: ci on: push: branches: - - main + - main pull_request: branches: - - main + - main jobs: doc: runs-on: ubuntu-latest steps: - - uses: actions/setup-python@v2 - with: - python-version: "3.x" - - uses: actions/checkout@v2 - - run: | - pip install sphinx - sphinx-build -M html docs/ build/ + - uses: actions/setup-python@v2 + with: + python-version: "3.x" + - uses: actions/checkout@v2 + - run: | + pip install sphinx + sphinx-build -M html docs/ build/ lint: runs-on: ubuntu-latest @@ -34,17 +34,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: [3.7, 3.8, 3.9] + # vtk not available for 3.10 yet + python-version: ["3.7", "3.8", "3.9"] steps: - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - uses: actions/checkout@v2 - with: - lfs: true - - name: Test with tox - run: | - pip install tox - tox -- --cov meshplex --cov-report xml --cov-report term - - uses: codecov/codecov-action@v1 - if: ${{ matrix.python-version == '3.9' }} + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - uses: actions/checkout@v2 + with: + lfs: true + - name: Test with tox + run: | + pip install tox + tox -- --cov meshplex --cov-report xml --cov-report term + - uses: codecov/codecov-action@v1 + if: ${{ matrix.python-version == '3.9' }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index ddcbfd7..8fb20e7 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,16 +1,16 @@ repos: - repo: https://github.com/PyCQA/isort - rev: 5.9.1 + rev: 5.9.3 hooks: - id: isort - - repo: https://github.com/python/black - rev: 21.6b0 + - repo: https://github.com/psf/black + rev: 21.9b0 hooks: - id: black language_version: python3 - - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.2 + - repo: https://github.com/PyCQA/flake8 + rev: 4.0.1 hooks: - id: flake8 diff --git a/README.md b/README.md index 77ec2f7..3f9600e 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ meshplex is used in [optimesh](https://github.com/nschloe/optimesh) and ### Quickstart meshplex can compute the following data: + ```python import meshplex @@ -64,8 +65,11 @@ print(mesh.num_delaunay_violations) # removes some cells mesh.remove_cells([0]) ``` + For triangular meshes (`MeshTri`), meshplex also has some mesh manipulation routines: + + ```python mesh.show() # show the mesh mesh.angles # compute angles @@ -81,9 +85,11 @@ For a documentation of all classes and functions, see ### Plotting #### Triangles + + ```python import meshplex @@ -100,9 +106,11 @@ mesh.show( ``` #### Tetrahedra + + ```python import numpy as np import meshplex @@ -142,11 +150,14 @@ mesh.show_cell( meshplex is [available from the Python Package Index](https://pypi.org/project/meshplex/), so simply type + ``` pip install meshplex ``` + to install. ### License + This software is published under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html). diff --git a/docs/conf.py b/docs/conf.py index 8d31af3..0942cf5 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,7 +10,8 @@ # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # -import os +import pathlib +from configparser import ConfigParser # import sys # sys.path.insert(0, os.path.abspath('.')) @@ -25,17 +26,11 @@ copyright = "2017-2021, Nico Schlömer" author = "Nico Schlömer" -# -# https://packaging.python.org/guides/single-sourcing-package-version/ -this_dir = os.path.abspath(os.path.dirname(__file__)) -about = {} -about_file = os.path.join(this_dir, "..", "src", "meshplex", "__about__.py") -with open(about_file) as f: - exec(f.read(), about) -# The short X.Y version. -# version = ".".join(about["__version__"].split(".")[:2]) -# The full version, including alpha/beta/rc tags. -release = about["__version__"] + +this_dir = pathlib.Path(__file__).resolve().parent +p = ConfigParser() +p.read(this_dir / ".." / "setup.cfg") +release = p["metadata"]["version"] # -- General configuration --------------------------------------------------- diff --git a/setup.cfg b/setup.cfg index b2d8db2..5260bee 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = meshplex -version = 0.16.5 +version = 0.16.6 author = Nico Schlömer author_email = nico.schloemer@gmail.com description = Fast tools for simplex meshes @@ -22,6 +22,7 @@ classifiers = Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 + Programming Language :: Python :: 3.10 Topic :: Scientific/Engineering Topic :: Scientific/Engineering :: Mathematics @@ -30,9 +31,8 @@ package_dir = =src packages = find: install_requires = - importlib_metadata;python_version<"3.8" meshio >=4, <6 - numpy >= 1.9 + numpy >= 1.20.0 npx >= 0.0.7 python_requires = >=3.7 diff --git a/src/meshplex/__about__.py b/src/meshplex/__about__.py deleted file mode 100644 index f85c205..0000000 --- a/src/meshplex/__about__.py +++ /dev/null @@ -1,10 +0,0 @@ -try: - # Python 3.8 - from importlib import metadata -except ImportError: - import importlib_metadata as metadata - -try: - __version__ = metadata.version("meshplex") -except Exception: - __version__ = "unknown" diff --git a/src/meshplex/__init__.py b/src/meshplex/__init__.py index 8661e13..82f9c21 100644 --- a/src/meshplex/__init__.py +++ b/src/meshplex/__init__.py @@ -1,4 +1,3 @@ -from .__about__ import __version__ from ._exceptions import MeshplexError from ._mesh import Mesh from ._mesh_tetra import MeshTetra @@ -6,7 +5,6 @@ from ._reader import from_meshio, read __all__ = [ - "__version__", "Mesh", "MeshTri", "MeshTetra", diff --git a/src/meshplex/_mesh.py b/src/meshplex/_mesh.py index fa71509..66a88fb 100644 --- a/src/meshplex/_mesh.py +++ b/src/meshplex/_mesh.py @@ -116,7 +116,7 @@ def __repr__(self): # prevent overriding points without adapting the other mesh data @property - def points(self): + def points(self) -> np.ndarray: return self._points @points.setter diff --git a/tests/test_io.py b/tests/test_io.py index a170d7d..99acd28 100644 --- a/tests/test_io.py +++ b/tests/test_io.py @@ -7,7 +7,9 @@ def test_io_2d(): - vertices, cells = meshzoo.rectangle_tri((0.0, 0.0), (1.0, 1.0), 2) + vertices, cells = meshzoo.rectangle_tri( + np.linspace(0.0, 1.0, 3), np.linspace(0.0, 1.0, 3) + ) mesh = meshplex.MeshTri(vertices, cells) # mesh = meshplex.read('pacman.vtu') assert mesh.num_delaunay_violations == 0 diff --git a/tox.ini b/tox.ini index 3d9fbd3..fe4488f 100644 --- a/tox.ini +++ b/tox.ini @@ -4,7 +4,7 @@ isolated_build = True [testenv] deps = - meshzoo + meshzoo >= 0.9.0 pytest pytest-cov pytest-codeblocks