diff --git a/.appveyor.yml b/.appveyor.yml index 458aad5..20cfcaf 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -21,7 +21,7 @@ build_script: - ps: | python -m build -s cd dist - python -m pip install --verbose pybind11_rdp-0.0.2.tar.gz + python -m pip install --verbose pybind11_rdp-0.1.0.tar.gz cd .. test_script: - ps: python -m pytest diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 8228b31..cdf965d 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -46,6 +46,8 @@ jobs: - uses: pypa/cibuildwheel@v2.11.1 env: CIBW_ARCHS_MACOS: auto universal2 + # https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip + CIBW_SKIP: pp* - name: Verify clean directory run: git diff --exit-code diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index af72c30..dfe8039 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -1,6 +1,6 @@ package: name: pybind11_rdp - version: 0.0.2 + version: 0.1.0 source: path: .. diff --git a/docs/conf.py b/docs/conf.py index a795652..2b44989 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -60,9 +60,9 @@ # built documents. # # The short X.Y version. -version = '0.0.2' +version = '0.1.0' # The full version, including alpha/beta/rc tags. -release = '0.0.2' +release = '0.1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/setup.py b/setup.py index ab15638..260cf0a 100644 --- a/setup.py +++ b/setup.py @@ -122,7 +122,7 @@ def build_extension(self, ext): # logic and declaration, and simpler if you include description/version in a file. setup( name="pybind11_rdp", - version="0.0.2", + version="0.1.0", author="tzx", author_email="dvorak4tzx@gmail.com", url="https://github.com/cubao/pybind11-rdp", diff --git a/src/main.cpp b/src/main.cpp index 83c7e93..8d543c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -135,6 +135,14 @@ PYBIND11_MODULE(pybind11_rdp, m) rdp_mask )pbdoc"; + py::class_(m, "LineSegment") // + .def(py::init(), "A"_a, + "B"_a) + .def("distance", &LineSegment::distance, "P"_a) + .def("distance2", &LineSegment::distance2, "P"_a) + // + ; + auto rdp_doc = R"pbdoc( Simplifies a given array of points using the Ramer-Douglas-Peucker algorithm. diff --git a/test.py b/test.py index 9d7b583..05c6045 100644 --- a/test.py +++ b/test.py @@ -1,10 +1,20 @@ import time import numpy as np +from pybind11_rdp import LineSegment from pybind11_rdp import rdp as rdp_pybind from pybind11_rdp import rdp_mask as rdp_mask from rdp import rdp as rdp_python +seg = LineSegment([0, 0, 0], [10, 0, 0]) +assert 4.0 == seg.distance([5.0, 4.0, 0.0]) +assert 5.0 == seg.distance([-4.0, 3.0, 0.0]) +assert 5.0 == seg.distance([14.0, 3.0, 0.0]) +seg = LineSegment([0, 0, 0], [0, 0, 0]) +assert 5.0 == seg.distance([3.0, 4.0, 0.0]) +assert 5.0 == seg.distance([-4.0, 3.0, 0.0]) +assert 13.0 == seg.distance([5.0, 12.0, 0.0]) + for fn in [rdp_python, rdp_pybind]: print("#" * 80) print(fn) diff --git a/tests/test_basic.py b/tests/test_basic.py index d0aabcd..4d88753 100644 --- a/tests/test_basic.py +++ b/tests/test_basic.py @@ -1,5 +1,18 @@ -import pybind11_rdp as m +from pybind11_rdp import LineSegment, rdp -def test_main(): - assert m.rdp([[1, 1], [2, 2], [3, 3], [4, 4]]).shape == (2, 2) +def test_segment(): + seg = LineSegment([0, 0, 0], [10, 0, 0]) + assert 4.0 == seg.distance([5.0, 4.0, 0.0]) + assert 5.0 == seg.distance([-4.0, 3.0, 0.0]) + assert 5.0 == seg.distance([14.0, 3.0, 0.0]) + seg = LineSegment([0, 0, 0], [0, 0, 0]) + assert 5.0 == seg.distance([3.0, 4.0, 0.0]) + assert 5.0 == seg.distance([-4.0, 3.0, 0.0]) + assert 13.0 == seg.distance([5.0, 12.0, 0.0]) + + +def test_rdp(): + assert rdp([[1, 1], [2, 2], [3, 3], [4, 4]], epsilon=1e-9).shape == (2, 2) + assert rdp([[0, 0], [5, 1 + 1e-3], [10, 0]], epsilon=1).shape == (3, 2) + assert rdp([[0, 0], [5, 1 - 1e-3], [10, 0]], epsilon=1).shape == (2, 2)