diff --git a/README.md b/README.md index d8eba4e016fa..fde39af7d6aa 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@
-

The Algorithms - Python

@@ -30,6 +29,10 @@ code style: black + + + +

All algorithms implemented in Python - for education

diff --git a/data_structures/kd_tree/tests/test_kdtree.py b/data_structures/kd_tree/tests/test_kdtree.py index 81f2cc990074..6df48b84efff 100644 --- a/data_structures/kd_tree/tests/test_kdtree.py +++ b/data_structures/kd_tree/tests/test_kdtree.py @@ -8,21 +8,20 @@ @pytest.mark.parametrize( - ("num_points", "cube_size", "num_dimensions", "depth", "expected_result"), + ("num_points", "cube_size", "num_dimensions", "expected_result"), [ - (0, 10.0, 2, 0, None), # Empty points list - (10, 10.0, 2, 2, KDNode), # Depth = 2, 2D points - (10, 10.0, 3, -2, KDNode), # Depth = -2, 3D points + (0, 10.0, 2, None), # Empty points list + (10, 10.0, 2, KDNode), # 2D points + (10, 10.0, 3, KDNode), # 3D points ], ) -def test_build_kdtree(num_points, cube_size, num_dimensions, depth, expected_result): +def test_build_kdtree(num_points, cube_size, num_dimensions, expected_result): """ Test that KD-Tree is built correctly. Cases: - Empty points list. - - Positive depth value. - - Negative depth value. + - Valid points list with correct dimensions. """ points = ( hypercube_points(num_points, cube_size, num_dimensions).tolist() @@ -30,24 +29,20 @@ def test_build_kdtree(num_points, cube_size, num_dimensions, depth, expected_res else [] ) - kdtree = build_kdtree(points, depth=depth) + kdtree = build_kdtree(points) if expected_result is None: # Empty points list case assert kdtree is None, f"Expected None for empty points list, got {kdtree}" else: - # Check if root node is not None + # Check if KD-Tree is built correctly assert kdtree is not None, "Expected a KDNode, got None" - - # Check if root has correct dimensions - assert ( - len(kdtree.point) == num_dimensions - ), f"Expected point dimension {num_dimensions}, got {len(kdtree.point)}" - - # Check that the tree is balanced to some extent (simplistic check) assert isinstance( kdtree, KDNode ), f"Expected KDNode instance, got {type(kdtree)}" + assert ( + len(kdtree.point) == num_dimensions + ), f"Expected point dimension {num_dimensions}, got {len(kdtree.point)}" def test_nearest_neighbour_search(): @@ -95,6 +90,4 @@ def test_edge_cases(): if __name__ == "__main__": - import pytest - pytest.main()