MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / test_edge_cases

Function test_edge_cases

data_structures/kd_tree/tests/test_kdtree.py:88–102  ·  view source on GitHub ↗

Test edge cases such as an empty KD-Tree.

()

Source from the content-addressed store, hash-verified

86
87
88def test_edge_cases():
89 """
90 Test edge cases such as an empty KD-Tree.
91 """
92 empty_kdtree = build_kdtree([])
93 query_point = [0.0] * 2 # Using a default 2D query point
94
95 nearest_point, nearest_dist, nodes_visited = nearest_neighbour_search(
96 empty_kdtree, query_point
97 )
98
99 # With an empty KD-Tree, nearest_point should be None
100 assert nearest_point is None
101 assert nearest_dist == float("inf")
102 assert nodes_visited == 0
103
104
105if __name__ == "__main__":

Callers

nothing calls this directly

Calls 2

build_kdtreeFunction · 0.90
nearest_neighbour_searchFunction · 0.90

Tested by

no test coverage detected