Skip to content

Commit 20a14fa

Browse files
initial commit of grid points test
1 parent f3d29d9 commit 20a14fa

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
3+
from diffpy.labpdfproc.functions import Gridded_circle
4+
5+
# Define test parameters
6+
params1 = [
7+
([0.5, 3, 1, {(0.0, -0.5), (0.0, 0.0), (-0.5, 0.0), (0.5, 0.0), (0.0, 0.5)}, 5]),
8+
([1, 4, 1, {(-0.333333, -0.333333), (0.333333, -0.333333), (-0.333333, 0.333333), (0.333333, 0.333333)}, 4]),
9+
]
10+
11+
12+
# Define the test function
13+
@pytest.mark.parametrize("params1", params1)
14+
def test_get_grid_points(params1):
15+
radius, n_points_on_diameter, mu, expected_grid, expected_total_points = params1
16+
17+
# Perform the test
18+
actual_gs = Gridded_circle(radius=radius, n_points_on_diameter=n_points_on_diameter, mu=mu)
19+
20+
# Sort both sets of points to compare
21+
actual_grid_sorted = sorted(actual_gs.grid)
22+
expected_grid_sorted = sorted(expected_grid)
23+
24+
# Assertions
25+
assert actual_gs.total_points_in_grid == expected_total_points
26+
for actual_point, expected_point in zip(actual_grid_sorted, expected_grid_sorted):
27+
assert actual_point == pytest.approx(expected_point, rel=1e-4, abs=1e-6)

0 commit comments

Comments
 (0)