From 1fd511c8d45221e1d632cee2d4b976eee003dd94 Mon Sep 17 00:00:00 2001 From: tang zhixiong Date: Wed, 2 Oct 2024 11:11:23 +0800 Subject: [PATCH 1/6] add stubs --- .gitignore | 1 + CMakeLists.txt | 2 +- Makefile | 4 ++++ src/concave_hull/_core.pyi | 31 +++++++++++++++++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/concave_hull/_core.pyi diff --git a/.gitignore b/.gitignore index 39aeec0..07eb143 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ _generate/ wheelhouse !test.py site +stubs diff --git a/CMakeLists.txt b/CMakeLists.txt index c2479fc..bcd1b0c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ endif() # https://scikit-build-core.readthedocs.io/en/latest/getting_started.html find_package(Python REQUIRED COMPONENTS Interpreter Development.Module) find_package(pybind11 CONFIG REQUIRED) -include_directories(BEFORE ${PROJECT_SOURCE_DIR}/headers/include) +include_directories(SYSTEM ${PROJECT_SOURCE_DIR}/headers/include) python_add_library(_core MODULE src/main.cpp WITH_SOABI) target_link_libraries(_core PRIVATE pybind11::headers) diff --git a/Makefile b/Makefile index 5e73e08..4e235b5 100644 --- a/Makefile +++ b/Makefile @@ -59,6 +59,10 @@ pytest: pytest tests/test_basic.py .PHONY: build +restub: + pybind11-stubgen concave_hull._core -o stubs + cp stubs/concave_hull/_core.pyi src/concave_hull + # conda create -y -n py36 python=3.6 # conda create -y -n py37 python=3.7 # conda create -y -n py38 python=3.8 diff --git a/src/concave_hull/_core.pyi b/src/concave_hull/_core.pyi new file mode 100644 index 0000000..14f084a --- /dev/null +++ b/src/concave_hull/_core.pyi @@ -0,0 +1,31 @@ +""" + + A very fast 2D concave hull algorithm + ------------------------------------- + + credits: + - https://github.com/mapbox/concaveman + - https://github.com/sadaszewski/concaveman-cpp + - https://cp-algorithms.com/geometry/convex-hull.html#implementation + +""" +from __future__ import annotations +import numpy +__all__ = ['clockwise', 'colinear', 'concave_hull_indexes', 'convex_hull_indexes', 'orientation', 'wgs84_to_east_north'] +def clockwise(prev: numpy.ndarray[numpy.float64[2, 1]], curr: numpy.ndarray[numpy.float64[2, 1]], next: numpy.ndarray[numpy.float64[2, 1]], *, include_colinear: bool = False) -> bool: + ... +def colinear(prev: numpy.ndarray[numpy.float64[2, 1]], curr: numpy.ndarray[numpy.float64[2, 1]], next: numpy.ndarray[numpy.float64[2, 1]]) -> bool: + ... +def concave_hull_indexes(points: numpy.ndarray[numpy.float64[m, 2]], *, convex_hull_indexes: numpy.ndarray[numpy.int32[m, 1]], concavity: float = 2.0, length_threshold: float = 0.0) -> numpy.ndarray[numpy.int32[m, 1]]: + """ + documents here: https://github.com/mapbox/concaveman + """ +def convex_hull_indexes(points: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous], *, include_colinear: bool = False, order_only: bool = False) -> numpy.ndarray[numpy.int32[m, 1]]: + ... +def orientation(prev: numpy.ndarray[numpy.float64[2, 1]], curr: numpy.ndarray[numpy.float64[2, 1]], next: numpy.ndarray[numpy.float64[2, 1]]) -> int: + ... +def wgs84_to_east_north(wgs84: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous]) -> numpy.ndarray[numpy.float64[m, 2]]: + """ + documents here: https://github.com/mapbox/cheap-ruler + """ +__version__: str = '0.0.7' From 593ca4cf668e89414433583613afb77a1bd98751 Mon Sep 17 00:00:00 2001 From: tang zhixiong Date: Thu, 3 Oct 2024 13:31:24 +0800 Subject: [PATCH 2/6] lint --- src/concave_hull/_core.pyi | 61 ++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 13 deletions(-) diff --git a/src/concave_hull/_core.pyi b/src/concave_hull/_core.pyi index 14f084a..58e5cde 100644 --- a/src/concave_hull/_core.pyi +++ b/src/concave_hull/_core.pyi @@ -7,25 +7,60 @@ - https://github.com/mapbox/concaveman - https://github.com/sadaszewski/concaveman-cpp - https://cp-algorithms.com/geometry/convex-hull.html#implementation - + """ from __future__ import annotations + import numpy -__all__ = ['clockwise', 'colinear', 'concave_hull_indexes', 'convex_hull_indexes', 'orientation', 'wgs84_to_east_north'] -def clockwise(prev: numpy.ndarray[numpy.float64[2, 1]], curr: numpy.ndarray[numpy.float64[2, 1]], next: numpy.ndarray[numpy.float64[2, 1]], *, include_colinear: bool = False) -> bool: - ... -def colinear(prev: numpy.ndarray[numpy.float64[2, 1]], curr: numpy.ndarray[numpy.float64[2, 1]], next: numpy.ndarray[numpy.float64[2, 1]]) -> bool: - ... -def concave_hull_indexes(points: numpy.ndarray[numpy.float64[m, 2]], *, convex_hull_indexes: numpy.ndarray[numpy.int32[m, 1]], concavity: float = 2.0, length_threshold: float = 0.0) -> numpy.ndarray[numpy.int32[m, 1]]: + +__all__ = [ + "clockwise", + "colinear", + "concave_hull_indexes", + "convex_hull_indexes", + "orientation", + "wgs84_to_east_north", +] + +def clockwise( + prev: numpy.ndarray[numpy.float64[2, 1]], + curr: numpy.ndarray[numpy.float64[2, 1]], + next: numpy.ndarray[numpy.float64[2, 1]], + *, + include_colinear: bool = False, +) -> bool: ... +def colinear( + prev: numpy.ndarray[numpy.float64[2, 1]], + curr: numpy.ndarray[numpy.float64[2, 1]], + next: numpy.ndarray[numpy.float64[2, 1]], +) -> bool: ... +def concave_hull_indexes( + points: numpy.ndarray[numpy.float64[m, 2]], + *, + convex_hull_indexes: numpy.ndarray[numpy.int32[m, 1]], + concavity: float = 2.0, + length_threshold: float = 0.0, +) -> numpy.ndarray[numpy.int32[m, 1]]: """ documents here: https://github.com/mapbox/concaveman """ -def convex_hull_indexes(points: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous], *, include_colinear: bool = False, order_only: bool = False) -> numpy.ndarray[numpy.int32[m, 1]]: - ... -def orientation(prev: numpy.ndarray[numpy.float64[2, 1]], curr: numpy.ndarray[numpy.float64[2, 1]], next: numpy.ndarray[numpy.float64[2, 1]]) -> int: - ... -def wgs84_to_east_north(wgs84: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous]) -> numpy.ndarray[numpy.float64[m, 2]]: + +def convex_hull_indexes( + points: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous], + *, + include_colinear: bool = False, + order_only: bool = False, +) -> numpy.ndarray[numpy.int32[m, 1]]: ... +def orientation( + prev: numpy.ndarray[numpy.float64[2, 1]], + curr: numpy.ndarray[numpy.float64[2, 1]], + next: numpy.ndarray[numpy.float64[2, 1]], +) -> int: ... +def wgs84_to_east_north( + wgs84: numpy.ndarray[numpy.float64[m, 2], numpy.ndarray.flags.c_contiguous] +) -> numpy.ndarray[numpy.float64[m, 2]]: """ documents here: https://github.com/mapbox/cheap-ruler """ -__version__: str = '0.0.7' + +__version__: str = "0.0.7" From 527840e72435e7a90da69c58b9c793c66566d30d Mon Sep 17 00:00:00 2001 From: tang zhixiong Date: Thu, 3 Oct 2024 15:04:54 +0800 Subject: [PATCH 3/6] fix --- docs/about/release-notes.md | 4 ++++ pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/about/release-notes.md b/docs/about/release-notes.md index baa3f0a..c4f81c8 100644 --- a/docs/about/release-notes.md +++ b/docs/about/release-notes.md @@ -10,6 +10,10 @@ To upgrade `concave_hull` to the latest version, use pip: pip install -U concave_hull ``` +## Version 0.0.8 (2024-10-03) + +* Add typing stubs + ## Version 0.0.7 (2024-01-06) * Strip useless code diff --git a/pyproject.toml b/pyproject.toml index 96c4f01..cf48ec0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "scikit_build_core.build" [project] name = "concave_hull" -version = "0.0.7" +version = "0.0.8" url = "https://concave-hull.readthedocs.io" description="A very fast 2D concave hull algorithm" readme = "README.md" From 792ed5da997347b193b7d8a8306db2d74e50f8d1 Mon Sep 17 00:00:00 2001 From: tang zhixiong Date: Thu, 3 Oct 2024 15:06:10 +0800 Subject: [PATCH 4/6] fix --- src/concave_hull/_core.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/concave_hull/_core.pyi b/src/concave_hull/_core.pyi index 58e5cde..7c4ae4d 100644 --- a/src/concave_hull/_core.pyi +++ b/src/concave_hull/_core.pyi @@ -63,4 +63,4 @@ def wgs84_to_east_north( documents here: https://github.com/mapbox/cheap-ruler """ -__version__: str = "0.0.7" +__version__: str = "0.0.8" From ce951f21c3f69248757668bc6de560980e888ca7 Mon Sep 17 00:00:00 2001 From: tang zhixiong Date: Thu, 3 Oct 2024 15:09:02 +0800 Subject: [PATCH 5/6] update --- .github/workflows/pip.yml | 4 ++-- .github/workflows/wheels.yml | 2 +- headers | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pip.yml b/.github/workflows/pip.yml index 61ec6f8..50bffbd 100644 --- a/.github/workflows/pip.yml +++ b/.github/workflows/pip.yml @@ -12,8 +12,8 @@ jobs: strategy: fail-fast: false matrix: - platform: [ubuntu-20.04, windows-2019, macos-11] - python-version: ["3.8", "3.9", "3.10"] + platform: [ubuntu-20.04, windows-2019, macos-13] + python-version: ["3.9"] runs-on: ${{ matrix.platform }} diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index f7df701..7aa231e 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -79,7 +79,7 @@ jobs: steps: - uses: actions/setup-python@v4 with: - python-version: "3.x" + python-version: "3.9" - uses: actions/download-artifact@v3 with: diff --git a/headers b/headers index 8ed287a..13b5b91 160000 --- a/headers +++ b/headers @@ -1 +1 @@ -Subproject commit 8ed287a7a1e2a5cd221271b19611ba4a3f33d15c +Subproject commit 13b5b9162c871fdc2fd3f264418fc704667b4bdc From 8901a33c4c0bd3ed96dc5ae7b03a3ca579bcd426 Mon Sep 17 00:00:00 2001 From: tang zhixiong Date: Thu, 3 Oct 2024 15:12:26 +0800 Subject: [PATCH 6/6] fix --- .github/workflows/wheels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 7aa231e..43d4ef5 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -49,7 +49,7 @@ jobs: with: platforms: all - - uses: pypa/cibuildwheel@v2.12.0 + - uses: pypa/cibuildwheel@v2.21.1 env: # CIBW_ARCHS: auto64 CIBW_ARCHS_LINUX: x86_64 aarch64