|
5 | 5 |
|
6 | 6 | params_q_to_tth = [ |
7 | 7 | # UC1: Empty q values, no wavelength, return empty arrays |
8 | | - ([None, np.empty((0))], np.empty((0))), |
9 | | - # UC2: Empty q values, wavelength specified, return empty arrays |
10 | | - ([4 * np.pi, np.empty((0))], np.empty(0)), |
| 8 | + (None, np.empty((0)), np.empty((0))), |
| 9 | + # # UC2: Empty q values, wavelength specified, return empty arrays |
| 10 | + (4 * np.pi, np.empty((0)), np.empty(0)), |
11 | 11 | # UC3: User specified valid q values, no wavelength, return empty arrays |
12 | 12 | ( |
13 | | - [None, np.array([0, 0.2, 0.4, 0.6, 0.8, 1])], |
| 13 | + None, |
| 14 | + np.array([0, 0.2, 0.4, 0.6, 0.8, 1]), |
14 | 15 | np.array([0, 1, 2, 3, 4, 5]), |
15 | 16 | ), |
16 | 17 | # UC4: User specified valid q values (with wavelength) |
17 | 18 | # expected tth values are 2*arcsin(q) in degrees |
18 | | - ([4 * np.pi, np.array([0, 1 / np.sqrt(2), 1.0])], np.array([0, 90.0, 180.0])), |
| 19 | + (4 * np.pi, np.array([0, 1 / np.sqrt(2), 1.0]), np.array([0, 90.0, 180.0])), |
19 | 20 | ] |
20 | 21 |
|
| 22 | +@pytest.mark.parametrize("wavelength, q, expected_tth", params_q_to_tth) |
| 23 | +def test_q_to_tth(wavelength, q, expected_tth): |
| 24 | + |
| 25 | + if wavelength is None: |
| 26 | + with pytest.warns(UserWarning, match="INFO: no wavelength has been specified"): |
| 27 | + actual_tth = q_to_tth(q, wavelength) |
| 28 | + else: |
| 29 | + actual_tth = q_to_tth(q, wavelength) |
21 | 30 |
|
22 | | -@pytest.mark.parametrize("inputs, expected", params_q_to_tth) |
23 | | -def test_q_to_tth(inputs, expected): |
24 | | - actual = q_to_tth(inputs[1], inputs[0]) |
25 | | - assert np.allclose(expected, actual) |
| 31 | + assert np.allclose(expected_tth, actual_tth) |
26 | 32 |
|
27 | 33 |
|
28 | 34 | params_q_to_tth_bad = [ |
|
0 commit comments