Skip to content

Commit 7fa73aa

Browse files
Merge branch 'main' into pkg
2 parents da2f9e3 + 069fb72 commit 7fa73aa

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
conda config --add channels conda-forge
4444
conda activate test
4545
conda install --file requirements/requirements.txt
46-
conda install pytest coverage codecov
46+
conda install --file requirements/requirements-dev.txt
4747
pip install .
4848
4949
- name: Validate diffpy.labpdfproc

requirements/requirements-dev.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ nbstripout
99
pre-commit
1010
pre-commit-hooks
1111
pytest
12+
pytest-mock
1213
sphinx
1314
twine
1415
# These are dependencies of various sphinx extensions for documentation.

src/diffpy/labpdfproc/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ def compute_cve(diffraction_data, mud, wavelength):
197197
"""
198198

199199
mu_sample_invmm = mud / 2
200-
abs_correction = Gridded_circle(mu=mu_sample_invmm)
200+
abs_correction = Gridded_circle(n_points_on_diameter=N_POINTS_ON_DIAMETER, mu=mu_sample_invmm)
201201
distances, muls = [], []
202202
for angle in TTH_GRID:
203203
abs_correction.set_distances_at_angle(angle)

src/diffpy/labpdfproc/tests/test_functions.py

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import numpy as np
12
import pytest
23

3-
from diffpy.labpdfproc.functions import Gridded_circle
4+
from diffpy.labpdfproc.functions import Gridded_circle, compute_cve
5+
from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object
46

57
params1 = [
68
([0.5, 3, 1], {(0.0, -0.5), (0.0, 0.0), (0.5, 0.0), (-0.5, 0.0), (0.0, 0.5)}),
@@ -52,3 +54,29 @@ def test_set_muls_at_angle(inputs, expected):
5254
actual_muls_sorted = sorted(actual_gs.muls)
5355
expected_muls_sorted = sorted(expected_muls)
5456
assert actual_muls_sorted == pytest.approx(expected_muls_sorted, rel=1e-4, abs=1e-6)
57+
58+
59+
def test_compute_cve(mocker):
60+
mocker.patch("diffpy.labpdfproc.functions.N_POINTS_ON_DIAMETER", 4)
61+
mocker.patch("diffpy.labpdfproc.functions.TTH_GRID", np.array([45, 60, 90]))
62+
input_pattern = Diffraction_object(wavelength=1.54)
63+
input_pattern.insert_scattering_quantity(
64+
np.array([45, 60, 90]),
65+
np.array([2.2, 3, 4]),
66+
"tth",
67+
scat_quantity="x-ray",
68+
name="test",
69+
metadata={"thing1": 1, "thing2": "thing2"},
70+
)
71+
actual_abdo = compute_cve(input_pattern, mud=1, wavelength=1.54)
72+
expected_abdo = Diffraction_object()
73+
expected_abdo.insert_scattering_quantity(
74+
np.array([45, 60, 90]),
75+
np.array([2.54253, 2.52852, 2.49717]),
76+
"tth",
77+
metadata={"thing1": 1, "thing2": "thing2"},
78+
name="absorption correction, cve, for test",
79+
wavelength=1.54,
80+
scat_quantity="cve",
81+
)
82+
assert actual_abdo == expected_abdo

0 commit comments

Comments
 (0)