| 1 |
import pytest |
| 2 |
|
| 3 |
import pycolmap |
| 4 |
|
| 5 |
|
| 6 |
def test_rotation_weight_type_enum(): |
| 7 |
assert { |
| 8 |
k: int(v) for k, v in pycolmap.RotationWeightType.__members__.items() |
| 9 |
} == { |
| 10 |
"GEMAN_MCCLURE": 0, |
| 11 |
"HALF_NORM": 1, |
| 12 |
} |
| 13 |
|
| 14 |
|
| 15 |
def test_rotation_averaging_reweighting_enum(): |
| 16 |
assert { |
| 17 |
k: int(v) |
| 18 |
for k, v in pycolmap.RotationAveragingReweighting.__members__.items() |
| 19 |
} == { |
| 20 |
"UNIFORM": 0, |
| 21 |
"INLIER_MATCH_COUNT": 1, |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
def test_rotation_estimator_options_default_init(): |
| 26 |
options = pycolmap.RotationEstimatorOptions() |
| 27 |
assert options is not None |
| 28 |
assert options.reweighting == pycolmap.RotationAveragingReweighting.UNIFORM |
| 29 |
|
| 30 |
|
| 31 |
def test_rotation_estimator_options_reweighting_readwrite(): |
| 32 |
options = pycolmap.RotationEstimatorOptions() |
| 33 |
options.reweighting = ( |
| 34 |
pycolmap.RotationAveragingReweighting.INLIER_MATCH_COUNT |
| 35 |
) |
| 36 |
assert ( |
| 37 |
options.reweighting |
| 38 |
== pycolmap.RotationAveragingReweighting.INLIER_MATCH_COUNT |
| 39 |
) |
| 40 |
options.reweighting = "UNIFORM" |
| 41 |
assert options.reweighting == pycolmap.RotationAveragingReweighting.UNIFORM |
| 42 |
|
| 43 |
|
| 44 |
def test_gravity_refiner_options_default_init(): |
| 45 |
options = pycolmap.GravityRefinerOptions() |
| 46 |
assert options is not None |
| 47 |
|
| 48 |
|
| 49 |
def test_gravity_refiner_options_max_outlier_ratio_readwrite(): |
| 50 |
options = pycolmap.GravityRefinerOptions() |
| 51 |
assert isinstance(options.max_outlier_ratio, float) |
| 52 |
options.max_outlier_ratio = 0.5 |
| 53 |
assert options.max_outlier_ratio == 0.5 |
| 54 |
|
| 55 |
|
| 56 |
def test_gravity_refiner_options_max_gravity_error_readwrite(): |
| 57 |
options = pycolmap.GravityRefinerOptions() |
| 58 |
assert isinstance(options.max_gravity_error, float) |
| 59 |
options.max_gravity_error = 10.0 |
| 60 |
assert options.max_gravity_error == 10.0 |
| 61 |
|
| 62 |
|
| 63 |
def test_gravity_refiner_options_min_num_neighbors_readwrite(): |
| 64 |
options = pycolmap.GravityRefinerOptions() |
| 65 |
assert isinstance(options.min_num_neighbors, int) |
| 66 |
options.min_num_neighbors = 5 |
| 67 |
assert options.min_num_neighbors == 5 |
| 68 |
|
| 69 |
|
| 70 |
def test_global_positioner_options_default_init(): |
| 71 |
options = pycolmap.GlobalPositionerOptions() |
| 72 |
assert options is not None |
| 73 |
|
| 74 |
|
| 75 |
@pytest.mark.parametrize( |
| 76 |
"name", |
| 77 |
[ |
| 78 |
"run_rotation_averaging", |
| 79 |
"run_gravity_refinement", |
| 80 |
"run_global_positioning", |
| 81 |
], |
| 82 |
) |
| 83 |
def test_public_api_callable(name): |
| 84 |
assert callable(getattr(pycolmap, name)) |