Skip to content

Commit 11df15f

Browse files
committed
add tests
1 parent 110d026 commit 11df15f

File tree

3 files changed

+82
-0
lines changed

3 files changed

+82
-0
lines changed

.github/workflows/test-package.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Test package
2+
3+
on: [push]
4+
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
strategy:
9+
matrix:
10+
python-version: [3.7, 3.8, 3.9]
11+
steps:
12+
# This cancels any such job that is still runnning
13+
- name: Cancel Previous Runs
14+
uses: styfle/[email protected]
15+
with:
16+
access_token: ${{ github.token }}
17+
- uses: actions/checkout@v2
18+
- name: Set up Python ${{ matrix.python-version }}
19+
uses: actions/setup-python@v2
20+
with:
21+
python-version: ${{ matrix.python-version }}
22+
- name: Install dependencies
23+
run: |
24+
pip install --upgrade pip
25+
pip install flake8 pytest
26+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
27+
pip install ncollpyde
28+
- name: Install skeletor
29+
run: |
30+
pip install -e .
31+
- name: Run tests
32+
run: |
33+
pytest --verbose

pytest.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[pytest]
2+
addopts = -v

tests/test_skeletor.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import skeletor as sk
2+
import trimesh as tm
3+
4+
5+
class TestPreprocessing:
6+
def test_example_mesh(self):
7+
"""Test loading the example mesh."""
8+
assert isinstance(sk.example_mesh(), tm.Trimesh)
9+
10+
def test_fix_mesh(self):
11+
fixed = sk.pre.fix_mesh(sk.example_mesh(),
12+
remove_disconnected=True, # this is off by default
13+
inplace=False)
14+
assert isinstance(fixed, tm.Trimesh)
15+
16+
def test_contraction(self):
17+
cont = sk.pre.contract(sk.example_mesh(), epsilon=0.1)
18+
assert isinstance(cont, tm.Trimesh)
19+
20+
21+
class TestSkeletonization:
22+
def test_wave_skeletonization(self):
23+
one_wave = sk.skeletonize.by_wavefront(sk.example_mesh(), waves=1)
24+
two_wave = sk.skeletonize.by_wavefront(sk.example_mesh(), waves=2)
25+
stepsize = sk.skeletonize.by_wavefront(sk.example_mesh(), waves=1,
26+
step_size=2)
27+
28+
def test_vertex_cluster(self):
29+
s = sk.skeletonize.by_vertex_clusters(sk.example_mesh(),
30+
sampling_dist=100)
31+
32+
def test_edge_collapse(self):
33+
s = sk.skeletonize.by_edge_collapse(sk.example_mesh())
34+
35+
36+
class TestPostprocessing:
37+
def test_cleanup(self):
38+
mesh = sk.example_mesh()
39+
s = sk.skeletonize.by_wavefront(mesh, waves=1)
40+
clean = sk.post.clean_up(s, inplace=False)
41+
42+
def test_radius(self):
43+
mesh = sk.example_mesh()
44+
s = sk.skeletonize.by_wavefront(mesh, waves=1)
45+
46+
rad_knn = sk.post.radii(s, method='knn')
47+
rad_ray = sk.post.radii(s, method='ray')

0 commit comments

Comments
 (0)