Skip to content

Commit

Permalink
add typing stubs (#25)
Browse files Browse the repository at this point in the history
* add stubs

* lint

* fix

* fix

* update

* fix

---------

Co-authored-by: tang zhixiong <[email protected]>
  • Loading branch information
district10 and zhixiong-tang authored Oct 3, 2024
1 parent bdca55e commit 078c7da
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ _generate/
wheelhouse
!test.py
site
stubs
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
66 changes: 66 additions & 0 deletions src/concave_hull/_core.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""
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.8"

0 comments on commit 078c7da

Please sign in to comment.