| 1 |
import numpy as np |
| 2 |
|
| 3 |
import pycolmap |
| 4 |
|
| 5 |
|
| 6 |
def test_point2d_default_init(): |
| 7 |
point = pycolmap.Point2D() |
| 8 |
assert point is not None |
| 9 |
|
| 10 |
|
| 11 |
def test_point2d_init_with_xy(): |
| 12 |
point = pycolmap.Point2D(xy=np.array([1.0, 2.0])) |
| 13 |
assert point is not None |
| 14 |
|
| 15 |
|
| 16 |
def test_point2d_init_with_xy_and_point3d_id(): |
| 17 |
point = pycolmap.Point2D(xy=np.array([1.0, 2.0]), point3D_id=5) |
| 18 |
assert point.point3D_id == 5 |
| 19 |
|
| 20 |
|
| 21 |
def test_point2d_xy_readwrite(): |
| 22 |
point = pycolmap.Point2D() |
| 23 |
point.xy = np.array([3.0, 4.0]) |
| 24 |
np.testing.assert_array_almost_equal(point.xy, [3.0, 4.0]) |
| 25 |
|
| 26 |
|
| 27 |
def test_point2d_x(): |
| 28 |
point = pycolmap.Point2D(xy=np.array([10.0, 20.0])) |
| 29 |
assert point.x() == 10.0 |
| 30 |
|
| 31 |
|
| 32 |
def test_point2d_y(): |
| 33 |
point = pycolmap.Point2D(xy=np.array([10.0, 20.0])) |
| 34 |
assert point.y() == 20.0 |
| 35 |
|
| 36 |
|
| 37 |
def test_point2d_point3d_id_readwrite(): |
| 38 |
point = pycolmap.Point2D() |
| 39 |
point.point3D_id = 42 |
| 40 |
assert point.point3D_id == 42 |
| 41 |
|
| 42 |
|
| 43 |
def test_point2d_has_point3d_false(): |
| 44 |
point = pycolmap.Point2D() |
| 45 |
assert not point.has_point3D() |
| 46 |
|
| 47 |
|
| 48 |
def test_point2d_has_point3d_true(): |
| 49 |
point = pycolmap.Point2D() |
| 50 |
point.point3D_id = 1 |
| 51 |
assert point.has_point3D() |
| 52 |
|
| 53 |
|
| 54 |
def test_point2d_list_append_and_len(): |
| 55 |
point_list = pycolmap.Point2DList() |
| 56 |
point_list.append(pycolmap.Point2D(xy=np.array([1.0, 2.0]))) |
| 57 |
point_list.append(pycolmap.Point2D(xy=np.array([3.0, 4.0]))) |
| 58 |
assert len(point_list) == 2 |