10
10
@pytest .mark .parametrize (
11
11
"num_points, cube_size, num_dimensions, depth, expected_result" ,
12
12
[
13
- (0 , 10.0 , 2 , 0 , None ), # Empty points list
14
- (10 , 10.0 , 2 , 2 , KDNode ), # Depth = 2, 2D points
13
+ (0 , 10.0 , 2 , 0 , None ), # Empty points list
14
+ (10 , 10.0 , 2 , 2 , KDNode ), # Depth = 2, 2D points
15
15
(10 , 10.0 , 3 , - 2 , KDNode ), # Depth = -2, 3D points
16
16
],
17
17
)
@@ -24,11 +24,13 @@ def test_build_kdtree(num_points, cube_size, num_dimensions, depth, expected_res
24
24
- Positive depth value.
25
25
- Negative depth value.
26
26
"""
27
- points = hypercube_points (num_points , cube_size , num_dimensions ).tolist () \
28
- if num_points > 0 \
27
+ points = (
28
+ hypercube_points (num_points , cube_size , num_dimensions ).tolist ()
29
+ if num_points > 0
29
30
else []
31
+ )
30
32
31
- kdtree = build_kdtree (points , depth = depth )
33
+ kdtree = build_kdtree (points , depth = depth )
32
34
33
35
if expected_result is None :
34
36
# Empty points list case
@@ -38,11 +40,14 @@ def test_build_kdtree(num_points, cube_size, num_dimensions, depth, expected_res
38
40
assert kdtree is not None , "Expected a KDNode, got None"
39
41
40
42
# Check if root has correct dimensions
41
- assert len (kdtree .point ) == num_dimensions , \
42
- f"Expected point dimension { num_dimensions } , got { len (kdtree .point )} "
43
+ assert (
44
+ len (kdtree .point ) == num_dimensions
45
+ ), f"Expected point dimension { num_dimensions } , got { len (kdtree .point )} "
43
46
44
47
# Check that the tree is balanced to some extent (simplistic check)
45
- assert isinstance (kdtree , KDNode ), f"Expected KDNode instance, got { type (kdtree )} "
48
+ assert isinstance (
49
+ kdtree , KDNode
50
+ ), f"Expected KDNode instance, got { type (kdtree )} "
46
51
47
52
48
53
def test_nearest_neighbour_search ():
0 commit comments