-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests comparing neighbor lists to trivial NHS (#15)
* Add tests comparing neighbor lists to trivial NHS * Extract search radius * Add `Random` as test dependency * Remove `using StaticArrays`
- Loading branch information
1 parent
9ac6ace
commit 84943ed
Showing
4 changed files
with
99 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[deps] | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
|
||
[compat] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Random | ||
|
||
# Generate a rectangular point cloud, optionally with a perturbation in the point positions | ||
function point_cloud(n_points_per_dimension; | ||
seed = 1, perturbation_factor_position = 1.0) | ||
# Fixed seed to ensure reproducibility | ||
Random.seed!(seed) | ||
|
||
n_dims = length(n_points_per_dimension) | ||
coordinates = Array{Float64}(undef, n_dims, prod(n_points_per_dimension)) | ||
cartesian_indices = CartesianIndices(n_points_per_dimension) | ||
|
||
for i in axes(coordinates, 2) | ||
coordinates[:, i] .= Tuple(cartesian_indices[i]) | ||
end | ||
|
||
perturb!(coordinates, perturbation_factor_position * 0.5) | ||
|
||
return coordinates | ||
end | ||
|
||
function perturb!(data, amplitude) | ||
for i in eachindex(data) | ||
# Perturbation in the interval (-amplitude, amplitude) | ||
data[i] += 2 * amplitude * rand() - amplitude | ||
end | ||
|
||
return data | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,5 @@ macro test_nowarn_mod(expr, additional_ignore_content = String[]) | |
end | ||
end | ||
end | ||
|
||
include("point_cloud.jl") |