Skip to content

Commit 79a1640

Browse files
district10TANG ZHIXIONG
andauthored
Feature/fix ci, export LineSegment, release 0.1.0 (#4)
* trigger wheels * update pip, install numpy * fix pyproject.toml; export LineSegment * disable all pp * change version * ready to PR * fix tests Co-authored-by: TANG ZHIXIONG <[email protected]>
1 parent 1fb6eea commit 79a1640

File tree

8 files changed

+41
-8
lines changed

8 files changed

+41
-8
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ build_script:
2121
- ps: |
2222
python -m build -s
2323
cd dist
24-
python -m pip install --verbose pybind11_rdp-0.0.2.tar.gz
24+
python -m pip install --verbose pybind11_rdp-0.1.0.tar.gz
2525
cd ..
2626
test_script:
2727
- ps: python -m pytest

.github/workflows/wheels.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
- uses: pypa/[email protected]
4747
env:
4848
CIBW_ARCHS_MACOS: auto universal2
49+
# https://cibuildwheel.readthedocs.io/en/stable/options/#build-skip
50+
CIBW_SKIP: pp*
4951

5052
- name: Verify clean directory
5153
run: git diff --exit-code

conda.recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package:
22
name: pybind11_rdp
3-
version: 0.0.2
3+
version: 0.1.0
44

55
source:
66
path: ..

docs/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@
6060
# built documents.
6161
#
6262
# The short X.Y version.
63-
version = '0.0.2'
63+
version = '0.1.0'
6464
# The full version, including alpha/beta/rc tags.
65-
release = '0.0.2'
65+
release = '0.1.0'
6666

6767
# The language for content autogenerated by Sphinx. Refer to documentation
6868
# for a list of supported languages.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def build_extension(self, ext):
122122
# logic and declaration, and simpler if you include description/version in a file.
123123
setup(
124124
name="pybind11_rdp",
125-
version="0.0.2",
125+
version="0.1.0",
126126
author="tzx",
127127
author_email="[email protected]",
128128
url="https://github.com/cubao/pybind11-rdp",

src/main.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ PYBIND11_MODULE(pybind11_rdp, m)
135135
rdp_mask
136136
)pbdoc";
137137

138+
py::class_<LineSegment>(m, "LineSegment") //
139+
.def(py::init<const Eigen::Vector3d, const Eigen::Vector3d>(), "A"_a,
140+
"B"_a)
141+
.def("distance", &LineSegment::distance, "P"_a)
142+
.def("distance2", &LineSegment::distance2, "P"_a)
143+
//
144+
;
145+
138146
auto rdp_doc = R"pbdoc(
139147
Simplifies a given array of points using the Ramer-Douglas-Peucker algorithm.
140148

test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,20 @@
11
import time
22

33
import numpy as np
4+
from pybind11_rdp import LineSegment
45
from pybind11_rdp import rdp as rdp_pybind
56
from pybind11_rdp import rdp_mask as rdp_mask
67
from rdp import rdp as rdp_python
78

9+
seg = LineSegment([0, 0, 0], [10, 0, 0])
10+
assert 4.0 == seg.distance([5.0, 4.0, 0.0])
11+
assert 5.0 == seg.distance([-4.0, 3.0, 0.0])
12+
assert 5.0 == seg.distance([14.0, 3.0, 0.0])
13+
seg = LineSegment([0, 0, 0], [0, 0, 0])
14+
assert 5.0 == seg.distance([3.0, 4.0, 0.0])
15+
assert 5.0 == seg.distance([-4.0, 3.0, 0.0])
16+
assert 13.0 == seg.distance([5.0, 12.0, 0.0])
17+
818
for fn in [rdp_python, rdp_pybind]:
919
print("#" * 80)
1020
print(fn)

tests/test_basic.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
1-
import pybind11_rdp as m
1+
from pybind11_rdp import LineSegment, rdp
22

33

4-
def test_main():
5-
assert m.rdp([[1, 1], [2, 2], [3, 3], [4, 4]]).shape == (2, 2)
4+
def test_segment():
5+
seg = LineSegment([0, 0, 0], [10, 0, 0])
6+
assert 4.0 == seg.distance([5.0, 4.0, 0.0])
7+
assert 5.0 == seg.distance([-4.0, 3.0, 0.0])
8+
assert 5.0 == seg.distance([14.0, 3.0, 0.0])
9+
seg = LineSegment([0, 0, 0], [0, 0, 0])
10+
assert 5.0 == seg.distance([3.0, 4.0, 0.0])
11+
assert 5.0 == seg.distance([-4.0, 3.0, 0.0])
12+
assert 13.0 == seg.distance([5.0, 12.0, 0.0])
13+
14+
15+
def test_rdp():
16+
assert rdp([[1, 1], [2, 2], [3, 3], [4, 4]], epsilon=1e-9).shape == (2, 2)
17+
assert rdp([[0, 0], [5, 1 + 1e-3], [10, 0]], epsilon=1).shape == (3, 2)
18+
assert rdp([[0, 0], [5, 1 - 1e-3], [10, 0]], epsilon=1).shape == (2, 2)

0 commit comments

Comments
 (0)