|
32 | 32 | @test neighbors == [1] |
33 | 33 | end |
34 | 34 |
|
35 | | - # @testset "Collision Handling With Non-Empty Cells" begin |
36 | | - # # Cell (-1, 0) with point 1 has a hash collision with cell (-2, -1) with point 2 |
37 | | - # coordinates = [[-0.05 -0.15]; [0.05 -0.05]] |
38 | | - # NDIMS = size(coordinates, 1) |
39 | | - # n_points = size(coordinates, 2) |
40 | | - # search_radius = 0.1 + 10 * eps() |
41 | | - # point_index = 1 |
| 35 | + @testset "Collision Handling With Non-Empty Cells" begin |
| 36 | + # Cell (-1, 0) with point 1 has a hash collision with cell (-2, -1) with point 2 |
| 37 | + coordinates = [[-0.05 -0.15]; [0.05 -0.05]] |
| 38 | + NDIMS = size(coordinates, 1) |
| 39 | + n_points = size(coordinates, 2) |
| 40 | + search_radius = 0.1 + 10 * eps() |
| 41 | + point_index = 1 |
42 | 42 |
|
43 | | - # nhs = GridNeighborhoodSearch{2}(; search_radius, n_points, |
44 | | - # cell_list = SpatialHashingCellList{NDIMS}(n_points)) |
45 | | - # initialize_grid!(nhs, coordinates) |
| 43 | + nhs = GridNeighborhoodSearch{2}(; search_radius, n_points, |
| 44 | + cell_list = SpatialHashingCellList{NDIMS}(n_points)) |
| 45 | + initialize_grid!(nhs, coordinates) |
46 | 46 |
|
47 | | - # @testset "Test For Collision" begin |
48 | | - # cell1 = (-1, 0) |
49 | | - # cell2 = (-2, -1) |
50 | | - # cell1_hash = PointNeighbors.spatial_hash(cell1, n_points) |
51 | | - # cell2_hash = PointNeighbors.spatial_hash(cell2, n_points) |
52 | | - # points1 = nhs.cell_list[cell1] |
53 | | - # points2 = nhs.cell_list[cell2] |
| 47 | + @testset "Test For Collision" begin |
| 48 | + cell1 = (-1, 0) |
| 49 | + cell2 = (-2, -1) |
| 50 | + cell1_hash = PointNeighbors.spatial_hash(cell1, n_points) |
| 51 | + cell2_hash = PointNeighbors.spatial_hash(cell2, n_points) |
| 52 | + points1 = nhs.cell_list[cell1] |
| 53 | + points2 = nhs.cell_list[cell2] |
54 | 54 |
|
55 | | - # @test sort(points1) == sort(points2) == [1, 2] |
56 | | - # @test cell1_hash == cell2_hash |
57 | | - # end |
| 55 | + @test sort(points1) == sort(points2) == [1, 2] |
| 56 | + @test cell1_hash == cell2_hash |
| 57 | + end |
58 | 58 |
|
59 | | - # neighbors = [Int[] for _ in axes(coordinates, 2)] |
60 | | - # foreach_point_neighbor(coordinates, coordinates, nhs, |
61 | | - # points = axes(coordinates, 2)) do point, neighbor, pos_diff, |
62 | | - # distance |
63 | | - # push!(neighbors[point], neighbor) |
64 | | - # end |
| 59 | + neighbors = [Int[] for _ in axes(coordinates, 2)] |
| 60 | + foreach_point_neighbor(coordinates, coordinates, nhs, |
| 61 | + points = axes(coordinates, 2)) do point, neighbor, pos_diff, |
| 62 | + distance |
| 63 | + push!(neighbors[point], neighbor) |
| 64 | + end |
65 | 65 |
|
66 | | - # @test neighbors[1] == [1] |
67 | | - # @test neighbors[2] == [2] |
68 | | - # end |
| 66 | + @test neighbors[1] == [1] |
| 67 | + @test neighbors[2] == [2] |
| 68 | + end |
69 | 69 | end |
0 commit comments