|
| 1 | +import numpy as np |
1 | 2 | import pytest
|
2 | 3 |
|
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 |
4 | 6 |
|
5 | 7 | params1 = [
|
6 | 8 | ([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):
|
52 | 54 | actual_muls_sorted = sorted(actual_gs.muls)
|
53 | 55 | expected_muls_sorted = sorted(expected_muls)
|
54 | 56 | assert actual_muls_sorted == pytest.approx(expected_muls_sorted, rel=1e-4, abs=1e-6)
|
| 57 | + |
| 58 | + |
| 59 | +def test_compute_cve(monkeypatch): |
| 60 | + monkeypatch.setattr("diffpy.labpdfproc.functions.N_POINTS_ON_DIAMETER", int(4)) |
| 61 | + monkeypatch.setattr("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.54253048, 2.52852515, 2.49717207]), |
| 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