-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(tests): add unit tests * feat(test): add .yaml for tests running * fix(ci): fix k3d requirements * fix(backend): fix unused_features property (#29) * fix(backend): fix unused_features property * fix(ci): fix flake8 issue
- Loading branch information
Showing
22 changed files
with
734 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Tests | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test-and-lint: | ||
strategy: | ||
matrix: | ||
os: [ ubuntu-22.04 ] | ||
python-version: [ "3.10" ] | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install Python${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install -r requirements.txt | ||
- name: Run pytest | ||
run: | | ||
python -m pytest tests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
1 2 3 4 | ||
1 2 3 4 | ||
1 2 3 4 | ||
0 0 0 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1 2 3 4 | ||
1 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
dataset: | ||
path: "path/to/dataset" | ||
patches: | ||
start: 0 | ||
end: 100 | ||
step: 10 | ||
iterations: 1 | ||
grid: | ||
voxel_edge_length: 8 | ||
subdividers: | ||
size: 2 | ||
segmenters: | ||
ransac: | ||
threshold: 0.01 | ||
initial_points: 6 | ||
iterations: 5000 | ||
backend: | ||
type: "eigen_factor" | ||
parameters: | ||
iterations_number: 5000 | ||
robust_type: HUBER | ||
output: | ||
visualization_path: "output" | ||
optimisation_path: "output" |
19 changes: 19 additions & 0 deletions
19
tests/data/yaml_configurations/incorrect_configuration_backend.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dataset: | ||
path: "path/to/dataset" | ||
patches: | ||
start: 0 | ||
end: 100 | ||
step: 10 | ||
iterations: 1 | ||
grid: | ||
voxel_edge_length: 8 | ||
subdividers: | ||
size: 2 | ||
segmenters: | ||
ransac: | ||
threshold: 0.01 | ||
initial_points: 6 | ||
iterations: 5000 | ||
output: | ||
visualization_path: "output" | ||
optimisation_path: "output" |
17 changes: 17 additions & 0 deletions
17
tests/data/yaml_configurations/incorrect_configuration_dataset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
grid: | ||
voxel_edge_length: 8 | ||
subdividers: | ||
size: 2 | ||
segmenters: | ||
ransac: | ||
threshold: 0.01 | ||
initial_points: 6 | ||
iterations: 5000 | ||
backend: | ||
type: "eigen_factor" | ||
parameters: | ||
iterations_number: 5000 | ||
robust_type: HUBER | ||
output: | ||
visualization_path: "output" | ||
optimisation_path: "output" |
19 changes: 19 additions & 0 deletions
19
tests/data/yaml_configurations/incorrect_configuration_patches.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dataset: | ||
path: "path/to/dataset" | ||
grid: | ||
voxel_edge_length: 8 | ||
subdividers: | ||
size: 2 | ||
segmenters: | ||
ransac: | ||
threshold: 0.01 | ||
initial_points: 6 | ||
iterations: 5000 | ||
backend: | ||
type: "eigen_factor" | ||
parameters: | ||
iterations_number: 5000 | ||
robust_type: HUBER | ||
output: | ||
visualization_path: "output" | ||
optimisation_path: "output" |
19 changes: 19 additions & 0 deletions
19
tests/data/yaml_configurations/incorrect_configuration_segmenters.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
dataset: | ||
path: "path/to/dataset" | ||
patches: | ||
start: 0 | ||
end: 100 | ||
step: 10 | ||
iterations: 1 | ||
grid: | ||
voxel_edge_length: 8 | ||
subdividers: | ||
size: 2 | ||
backend: | ||
type: "eigen_factor" | ||
parameters: | ||
iterations_number: 5000 | ||
robust_type: HUBER | ||
output: | ||
visualization_path: "output" | ||
optimisation_path: "output" |
22 changes: 22 additions & 0 deletions
22
tests/data/yaml_configurations/incorrect_configuration_subdividers.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
dataset: | ||
path: "path/to/dataset" | ||
patches: | ||
start: 0 | ||
end: 100 | ||
step: 10 | ||
iterations: 1 | ||
grid: | ||
voxel_edge_length: 8 | ||
segmenters: | ||
ransac: | ||
threshold: 0.01 | ||
initial_points: 6 | ||
iterations: 5000 | ||
backend: | ||
type: "eigen_factor" | ||
parameters: | ||
iterations_number: 5000 | ||
robust_type: HUBER | ||
output: | ||
visualization_path: "output" | ||
optimisation_path: "output" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import random | ||
|
||
from slam.segmenter import CAPESegmenter | ||
from slam.typing import ArrayNx3 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"points, correlation, points_size", | ||
[ | ||
( | ||
[ | ||
np.array( | ||
[random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)] | ||
) | ||
for _ in range(100) | ||
], | ||
100, | ||
100, | ||
), | ||
( | ||
[ | ||
np.array( | ||
[random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)] | ||
) | ||
for _ in range(100) | ||
], | ||
0, | ||
0, | ||
), | ||
], | ||
) | ||
def test_cape_segmenter( | ||
points: ArrayNx3[float], | ||
correlation: float, | ||
points_size: int, | ||
): | ||
cape_segmenter = CAPESegmenter(correlation) | ||
actual_points = cape_segmenter(points) | ||
assert len(actual_points) == points_size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from slam.segmenter import CountSegmenter | ||
from slam.typing import ArrayNx3 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"points, count, expected_points", | ||
[ | ||
(np.array([[0, 0, 0]]), 0, np.array([[0, 0, 0]])), | ||
(np.array([[0, 0, 0]]), 10, np.empty((0, 3))), | ||
], | ||
) | ||
def test_count_segmenter( | ||
points: ArrayNx3[float], | ||
count: int, | ||
expected_points: ArrayNx3[float], | ||
): | ||
count_segmenter = CountSegmenter(count=count) | ||
actual_points = count_segmenter(points) | ||
assert len(actual_points) == len(expected_points) | ||
assert np.all(actual_points == expected_points) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from slam.subdivider import CountSubdivider | ||
from slam.typing import ArrayNx3 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"points, count, expected_decision", | ||
[ | ||
( | ||
np.array( | ||
[ | ||
[0, 0, 0], | ||
[0, 1, 0], | ||
[1, 1, 1], | ||
] | ||
), | ||
1, | ||
True, | ||
), | ||
( | ||
np.array( | ||
[ | ||
[0, 0, 0], | ||
[0, 1, 0], | ||
[1, 1, 1], | ||
] | ||
), | ||
5, | ||
False, | ||
), | ||
( | ||
np.empty((0, 3)), | ||
1, | ||
False, | ||
), | ||
], | ||
) | ||
def test_count_subdivider( | ||
points: ArrayNx3[float], | ||
count: float, | ||
expected_decision: bool, | ||
): | ||
count_subdivider = CountSubdivider(count=count) | ||
assert expected_decision == count_subdivider(points) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
import random | ||
|
||
from slam.subdivider import EigenValueSubdivider | ||
from slam.typing import ArrayNx3 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"points, eigen_value, expected_decision", | ||
[ | ||
( | ||
[ | ||
np.array( | ||
[random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)] | ||
) | ||
for _ in range(100) | ||
], | ||
1, | ||
False, | ||
), | ||
( | ||
[ | ||
np.array( | ||
[random.uniform(0, 1), random.uniform(0, 1), random.uniform(0, 1)] | ||
) | ||
for _ in range(100) | ||
], | ||
1000, | ||
False, | ||
), | ||
( | ||
np.empty((0, 3)), | ||
1, | ||
False, | ||
), | ||
], | ||
) | ||
def test_eigen_value_subdivider( | ||
points: ArrayNx3[float], | ||
eigen_value: float, | ||
expected_decision: bool, | ||
): | ||
eigen_value_subdivider = EigenValueSubdivider(value=eigen_value) | ||
assert expected_decision == eigen_value_subdivider(points) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from slam.filter import EmptyVoxel | ||
from slam.typing import ArrayNx3 | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"points, expected_decision", | ||
[ | ||
(np.array([0, 0, 0]), True), | ||
(np.empty(0), False), | ||
], | ||
) | ||
def test_empty_voxel(points: ArrayNx3[float], expected_decision: bool): | ||
empty_voxel_filter = EmptyVoxel() | ||
assert empty_voxel_filter(points) == expected_decision |
Oops, something went wrong.