-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d028ae5
commit 49a514b
Showing
3 changed files
with
62 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
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,38 @@ | ||
import numpy as np | ||
import pytest | ||
|
||
from diffpy.labpdfproc.functions import Gridded_circle | ||
|
||
|
||
def test_get_grid_points(): | ||
actual_gs = Gridded_circle(radius=1, n_points_on_diameter=3, mu=1) | ||
expected_gs = Gridded_circle() | ||
expected_gs.grid = {(0.0, -1.0), (0.0, 0.0), (-1.0, 0.0), (1.0, 0.0), (0.0, 1.0)} | ||
expected_gs.total_points_in_grid = 5 | ||
assert actual_gs.grid == expected_gs.grid | ||
assert actual_gs.total_points_in_grid == expected_gs.total_points_in_grid | ||
|
||
|
||
""" | ||
class TestGetGridPoints: | ||
def setUp(self): | ||
self.radius = 5 | ||
self.npoints = 10 | ||
self._get_grid_points() | ||
# | ||
self.radius = 0.5 | ||
self.grid = [(-0.026315789473684237, -0.4473684210526316), | ||
(0.13157894736842102, -0.2368421052631579), | ||
(0.18421052631578938, 0.02631578947368418), | ||
(0.3421052631578947, 0.18421052631578938), | ||
(0.02631578947368418, -0.4473684210526316), | ||
(0.18421052631578938, -0.2368421052631579), | ||
(0.2894736842105263, 0.07894736842105265), | ||
(0.2894736842105263, 0.18421052631578938), | ||
(-0.1842105263157895, -0.39473684210526316), | ||
(0.23684210526315785, -0.2368421052631579), | ||
(-0.2368421052631579, 0.07894736842105265), | ||
(0.23684210526315785, 0.18421052631578938)] | ||
#self.total_points_in_grid = len(self.grid) | ||
""" |
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,23 @@ | ||
import pytest | ||
|
||
from diffpy.labpdfproc.functions import Gridded_circle | ||
|
||
|
||
def test_set_distances_at_angle(): | ||
actual_gs = Gridded_circle(radius=1, n_points_on_diameter=3, mu=1) | ||
|
||
# tests for acute angles | ||
actual_gs.set_distances_at_angle(25) | ||
actual_acute = actual_gs.distances | ||
expected_acute = [0, 2, 1.81261557406, 2, 0.845236523481399] | ||
assert actual_acute == pytest.approx(expected_acute, rel=1e-4, abs=1e-6) | ||
|
||
actual_gs.set_distances_at_angle(90) | ||
actual_right = actual_gs.distances | ||
expected_right = [0, 2, 0, 2, 2] | ||
assert actual_right == pytest.approx(expected_right, rel=1e-4, abs=1e-6) | ||
|
||
actual_gs.set_distances_at_angle(140) | ||
actual_obtuse = actual_gs.distances | ||
expected_obtuse = [0, 2, 0, 3.5320888862379562, 1.2855752193730785] | ||
assert actual_obtuse == pytest.approx(expected_obtuse, rel=1e-4, abs=1e-6) |