Skip to content

Commit 68f8e45

Browse files
add test for apply_corr
1 parent 3d33c25 commit 68f8e45

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/diffpy/labpdfproc/tests/test_functions.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import numpy as np
22
import pytest
33

4-
from diffpy.labpdfproc.functions import Gridded_circle, compute_cve
4+
from diffpy.labpdfproc.functions import Gridded_circle, apply_corr, compute_cve
55
from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object
66

77
params1 = [
@@ -83,3 +83,20 @@ def test_compute_cve(mocker):
8383
scat_quantity="cve",
8484
)
8585
assert actual_abdo == expected_abdo
86+
87+
88+
def test_apply_corr(mocker):
89+
xarray, yarray = np.array([90, 90.1, 90.2]), np.array([2, 2, 2])
90+
expected_cve = np.array([0.5, 0.5, 0.5])
91+
mocker.patch("diffpy.labpdfproc.functions.TTH_GRID", xarray)
92+
mocker.patch("numpy.interp", return_value=expected_cve)
93+
input_pattern = _instantiate_test_do(xarray, yarray)
94+
absorption_correction = _instantiate_test_do(
95+
xarray,
96+
expected_cve,
97+
name="absorption correction, cve, for test",
98+
scat_quantity="cve",
99+
)
100+
actual_corr = apply_corr(input_pattern, absorption_correction)
101+
expected_corr = _instantiate_test_do(xarray, np.array([1, 1, 1]))
102+
assert actual_corr == expected_corr

0 commit comments

Comments
 (0)