|
3 | 3 | import numpy as np |
4 | 4 | import pytest |
5 | 5 |
|
6 | | -from diffpy.labpdfproc.functions import ( |
7 | | - CVE_METHODS, |
8 | | - Gridded_circle, |
9 | | - apply_corr, |
10 | | - compute_cve, |
11 | | - interpolate_to_xtype_grid, |
12 | | -) |
| 6 | +from diffpy.labpdfproc.functions import CVE_METHODS, Gridded_circle, apply_corr, compute_cve |
13 | 7 | from diffpy.utils.scattering_objects.diffraction_objects import Diffraction_object |
14 | 8 |
|
15 | 9 | params1 = [ |
@@ -78,44 +72,23 @@ def _instantiate_test_do(xarray, yarray, xtype="tth", name="test", scat_quantity |
78 | 72 |
|
79 | 73 |
|
80 | 74 | params4 = [ |
81 | | - ([np.array([30, 60, 90]), np.array([1, 2, 3]), "tth"], [np.array([30, 60, 90]), np.array([1, 2, 3]), "tth"]), |
82 | | - ( |
83 | | - [np.array([30, 60, 90]), np.array([1, 2, 3]), "q"], |
84 | | - [np.array([2.11195, 4.07999, 5.76998]), np.array([1, 1, 1]), "q"], |
85 | | - ), |
| 75 | + (["tth"], [np.array([90, 90.1, 90.2]), np.array([0.5, 0.5, 0.5]), "tth"]), |
| 76 | + (["q"], [np.array([5.76998, 5.77501, 5.78004]), np.array([0.5, 0.5, 0.5]), "q"]), |
86 | 77 | ] |
87 | 78 |
|
88 | 79 |
|
89 | 80 | @pytest.mark.parametrize("inputs, expected", params4) |
90 | | -def test_interpolate_xtype(inputs, expected, mocker): |
91 | | - expected_cve_do = _instantiate_test_do( |
92 | | - expected[0], |
93 | | - expected[1], |
94 | | - xtype=expected[2], |
95 | | - name="absorption correction, cve, for test", |
96 | | - scat_quantity="cve", |
97 | | - ) |
98 | | - input_cve_do = _instantiate_test_do( |
99 | | - inputs[0], |
100 | | - inputs[1], |
101 | | - xtype="tth", |
102 | | - name="absorption correction, cve, for test", |
103 | | - scat_quantity="cve", |
104 | | - ) |
105 | | - actual_cve_do = interpolate_to_xtype_grid(input_cve_do, xtype=inputs[2]) |
106 | | - assert actual_cve_do == expected_cve_do |
107 | | - |
108 | | - |
109 | | -def test_compute_cve(mocker): |
| 81 | +def test_compute_cve(inputs, expected, mocker): |
110 | 82 | xarray, yarray = np.array([90, 90.1, 90.2]), np.array([2, 2, 2]) |
111 | 83 | expected_cve = np.array([0.5, 0.5, 0.5]) |
112 | 84 | mocker.patch("diffpy.labpdfproc.functions.TTH_GRID", xarray) |
113 | 85 | mocker.patch("numpy.interp", return_value=expected_cve) |
114 | 86 | input_pattern = _instantiate_test_do(xarray, yarray) |
115 | | - actual_cve_do = compute_cve(input_pattern, mud=1) |
| 87 | + actual_cve_do = compute_cve(input_pattern, mud=1, method="polynomial_interpolation", xtype=inputs[0]) |
116 | 88 | expected_cve_do = _instantiate_test_do( |
117 | | - xarray, |
118 | | - expected_cve, |
| 89 | + expected[0], |
| 90 | + expected[1], |
| 91 | + expected[2], |
119 | 92 | name="absorption correction, cve, for test", |
120 | 93 | scat_quantity="cve", |
121 | 94 | ) |
|
0 commit comments