Skip to content

Commit 26ab884

Browse files
committed
Add unit tests
1 parent 0a8e3bc commit 26ab884

19 files changed

+842
-1887
lines changed

.github/workflows/tests.yml

Lines changed: 84 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,91 @@ jobs:
2727
run: |
2828
conda activate abspy
2929
pip install --upgrade .
30+
31+
- name: Install pytest
32+
shell: bash -l {0}
33+
run: |
34+
conda activate abspy
35+
pip install pytest
36+
37+
- name: Run unit tests
38+
shell: bash -l {0}
39+
run: |
40+
conda activate abspy
41+
pytest tests/ -v
42+
43+
- name: Run tutorial_complex.py
44+
continue-on-error: true
45+
id: tutorial_complex
46+
shell: bash -l {0}
47+
run: |
48+
conda activate abspy
49+
echo "Running tutorial_complex.py..."
50+
python tutorials/tutorial_complex.py
3051
31-
- name: Run tests
52+
- name: Run tutorial_primitive.py
53+
continue-on-error: true
54+
id: tutorial_primitive
3255
shell: bash -l {0}
3356
run: |
3457
conda activate abspy
35-
python tests/test_complex.py
36-
python tests/test_primitive.py
37-
python tests/test_graph.py
38-
python tests/test_combined.py
58+
echo "Running tutorial_primitive.py..."
59+
python tutorials/tutorial_primitive.py
60+
61+
- name: Run tutorial_graph.py
62+
continue-on-error: true
63+
id: tutorial_graph
64+
shell: bash -l {0}
65+
run: |
66+
conda activate abspy
67+
echo "Running tutorial_graph.py..."
68+
python tutorials/tutorial_graph.py
69+
70+
- name: Run tutorial_combined.py
71+
continue-on-error: true
72+
id: tutorial_combined
73+
shell: bash -l {0}
74+
run: |
75+
conda activate abspy
76+
echo "Running tutorial_combined.py..."
77+
python tutorials/tutorial_combined.py
78+
79+
- name: Check tutorial execution status
80+
shell: bash -l {0}
81+
run: |
82+
echo "Checking tutorial execution results:"
83+
84+
if [ "${{ steps.tutorial_complex.outcome }}" == "success" ]; then
85+
echo "✅ tutorial_complex.py executed successfully"
86+
else
87+
echo "❌ tutorial_complex.py failed"
88+
exit_code=1
89+
fi
90+
91+
if [ "${{ steps.tutorial_primitive.outcome }}" == "success" ]; then
92+
echo "✅ tutorial_primitive.py executed successfully"
93+
else
94+
echo "❌ tutorial_primitive.py failed"
95+
exit_code=1
96+
fi
97+
98+
if [ "${{ steps.tutorial_graph.outcome }}" == "success" ]; then
99+
echo "✅ tutorial_graph.py executed successfully"
100+
else
101+
echo "❌ tutorial_graph.py failed"
102+
exit_code=1
103+
fi
104+
105+
if [ "${{ steps.tutorial_combined.outcome }}" == "success" ]; then
106+
echo "✅ tutorial_combined.py executed successfully"
107+
else
108+
echo "❌ tutorial_combined.py failed"
109+
exit_code=1
110+
fi
111+
112+
if [ -n "$exit_code" ]; then
113+
echo "One or more tutorials failed. Check the logs above for details."
114+
exit 1
115+
else
116+
echo "All tutorials executed successfully!"
117+
fi

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ dmypy.json
130130
# Pycharm
131131
.idea/
132132

133-
# data and output
134-
tests/test_data/
135-
tests/test_output/
133+
# Visual Studio Code
134+
.vscode/
136135

136+
# data and output
137+
data/
138+
output/

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
### Added
9+
- Unit tests integrated with GitHub Actions workflow.
10+
11+
### Changed
12+
- Rename previous `tests` to `tutorials`.
13+
- `CellComplex.prioritise_planes` defaults `prioritise_verticals=False`.
14+
15+
## [0.2.6] - 2025-02-03
16+
### Added
917
- `engine='mesh'` for `AdjacencyGraph.save_surface_obj` for mesh output (https://github.com/chenzhaiyu/abspy/issues/18).
1018
- `.github/workflows/tests.yml`
1119
- `CONTRIBUTING.md`

abspy/complex.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ def __init__(self, planes, aabbs, obbs=None, points=None, initial_bound=None, in
9797
# missing planes due to occlusion or incapacity of RANSAC
9898
self.additional_planes = additional_planes
9999

100-
self.initial_bound = initial_bound if initial_bound else self._pad_bound(
100+
# Fix: Use explicit None check instead of boolean evaluation which is ambiguous for arrays
101+
self.initial_bound = initial_bound if initial_bound is not None else self._pad_bound(
101102
[np.amin(aabbs[:, 0, :], axis=0), np.amax(aabbs[:, 1, :], axis=0)],
102103
padding=initial_padding)
103104
self.cells = [self._construct_initial_cell()] # list of QQ
@@ -152,7 +153,7 @@ def refine_planes(self, theta=10 * 3.1416 / 180, epsilon=0.005, normalise_normal
152153
# shallow copy of the primitives
153154
planes = list(copy(self.planes))
154155
aabbs = list(copy(self.aabbs))
155-
obbs = list(copy(self.obbs))
156+
obbs = list(copy(self.obbs)) if self.obbs is not None else []
156157
points = list(copy(self.points))
157158

158159
# pre-compute cosine of theta
@@ -224,7 +225,7 @@ def refine_planes(self, theta=10 * 3.1416 / 180, epsilon=0.005, normalise_normal
224225
self.obbs = np.array(obbs)
225226
self.points = np.array(points, dtype=object)
226227

227-
def prioritise_planes(self, prioritise_verticals=True):
228+
def prioritise_planes(self, prioritise_verticals=False):
228229
"""
229230
Prioritise certain planes to favour building reconstruction.
230231

0 commit comments

Comments
 (0)