Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
alavenant committed Oct 4, 2024
1 parent 0cc1502 commit 97abab2
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/test_radius_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def run_filter(arrays_las, distance_radius, search_3d, limit_z_above=-1, limit_w
return nb_pts_radius_search


def build_random_points_around_one_point(test_function):
def build_random_points_around_one_point(test_function, points=[]):

dtype = [("X", "<f8"), ("Y", "<f8"), ("Z", "<f8"), ("Classification", "u1")]
arrays_las = np.array([pt_ini], dtype=dtype)
Expand All @@ -90,6 +90,15 @@ def build_random_points_around_one_point(test_function):
arrays_las = np.concatenate((arrays_las, arrays_pti), axis=0)
nb_points_take += test_function(pt_limit)

arrays_pti = np.array([pt_ini], dtype=dtype)
arrays_las = np.concatenate((arrays_las, arrays_pti), axis=0)
nb_points_take = test_function(pt_limit)

for pt in points:
arrays_pt = np.array([pt], dtype=dtype)
arrays_las = np.concatenate((arrays_las, arrays_pt), axis=0)
nb_points_take += test_function(pt)

nb_points = rand.randint(20, 50)
for i in range(nb_points):
# round at 1 to avoid precision numeric pb
Expand Down Expand Up @@ -163,14 +172,17 @@ def test_radius_assign_2d_cylinder_above():
limit_z_below = -1
limit_z_above = 1.75

points = []
points.append((pt_x, pt_y, pt_z + limit_z_above, 2))

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt_ini[2] - pt[2]
if distance_i < distance_radius and distance_z < limit_z_above:
return 1
return 0

arrays_las, nb_points_take_2d = build_random_points_around_one_point(func_test)
arrays_las, nb_points_take_2d = build_random_points_around_one_point(func_test, points)

nb_pts_radius_2d_cylinder = run_filter(
arrays_las, distance_radius, False, limit_z_above, limit_z_below
Expand Down Expand Up @@ -243,6 +255,10 @@ def test_radius_assign_2d_cylinder_above_and_bellow(execution_number):
limit_z_below = rand.uniform(0, 2)
limit_z_above = rand.uniform(0, 2)

points = []
points.append((pt_x, pt_y, pt_z + limit_z_above, 2))
points.append((pt_x, pt_y, pt_z - limit_z_below, 2))

def func_test(pt):
distance_i = distance2d(pt_ini, pt)
distance_z = pt_ini[2] - pt[2]
Expand All @@ -254,7 +270,7 @@ def func_test(pt):
return 1
return 0

arrays_las, nb_points_take_2d = build_random_points_around_one_point(func_test)
arrays_las, nb_points_take_2d = build_random_points_around_one_point(func_test, points)

nb_pts_radius_2d_cylinder = run_filter(
arrays_las, distance_radius, False, limit_z_above, limit_z_below
Expand Down

0 comments on commit 97abab2

Please sign in to comment.