|
4 | 4 |
|
5 | 5 | from diffpy.morph.morphs.morphsqueeze import MorphSqueeze |
6 | 6 |
|
7 | | -squeeze_coeffs_list = [ |
8 | | - # The order of coefficients is [a0, a1, a2, ..., an] |
| 7 | +squeeze_coeffs_dic = [ |
| 8 | + # The order of coefficients is {a0, a1, a2, ..., an} |
9 | 9 | # Negative cubic squeeze coefficients |
10 | | - [-0.01, -0.0005, -0.0005, -1e-6], |
| 10 | + {"a0": -0.01, "a1": -0.0005, "a2": -0.0005, "a3": -1e-6}, |
11 | 11 | # Positive cubic squeeze coefficients |
12 | | - [0.2, 0.01, 0.001, 0.0001], |
| 12 | + {"a0": 0.2, "a1": 0.01, "a2": 0.001, "a3": 0.0001}, |
13 | 13 | # Positive and negative cubic squeeze coefficients |
14 | | - [0.2, -0.01, 0.002, -0.0001], |
| 14 | + {"a0": 0.2, "a1": -0.01, "a2": 0.002, "a3": -0.0001}, |
15 | 15 | # Quadratic squeeze coefficients |
16 | | - [-0.2, 0.005, -0.0004], |
| 16 | + {"a0": -0.2, "a1": 0.005, "a2": -0.0004}, |
17 | 17 | # Linear squeeze coefficients |
18 | | - [0.1, 0.3], |
| 18 | + {"a0": 0.1, "a1": 0.3}, |
19 | 19 | # 4th order squeeze coefficients |
20 | | - [0.2, -0.01, 0.001, -0.001, 0.0001], |
| 20 | + {"a0": 0.2, "a1": -0.01, "a2": 0.001, "a3": -0.001, "a4": 0.0001}, |
21 | 21 | # Zeros and non-zeros, the full polynomial is applied |
22 | | - [0, 0.03, 0, -0.0001], |
| 22 | + {"a0": 0, "a1": 0.03, "a2": 0, "a3": -0.0001}, |
23 | 23 | # Testing zeros, expect no squeezing |
24 | | - [0, 0, 0, 0, 0, 0], |
| 24 | + {"a0": 0, "a1": 0, "a2": 0, "a3": 0, "a4": 0, "a5": 0}, |
25 | 25 | ] |
26 | 26 | morph_target_grids = [ |
27 | 27 | # UCs from issue 181: https://github.com/diffpy/diffpy.morph/issues/181 |
|
41 | 41 |
|
42 | 42 |
|
43 | 43 | @pytest.mark.parametrize("x_morph, x_target", morph_target_grids) |
44 | | -@pytest.mark.parametrize("squeeze_coeffs", squeeze_coeffs_list) |
| 44 | +@pytest.mark.parametrize("squeeze_coeffs", squeeze_coeffs_dic) |
45 | 45 | def test_morphsqueeze(x_morph, x_target, squeeze_coeffs): |
46 | 46 | y_target = np.sin(x_target) |
47 | | - squeeze_polynomial = Polynomial(squeeze_coeffs) |
| 47 | + coeffs = [squeeze_coeffs[f"a{i}"] for i in range(len(squeeze_coeffs))] |
| 48 | + squeeze_polynomial = Polynomial(coeffs) |
48 | 49 | x_squeezed = x_morph + squeeze_polynomial(x_morph) |
49 | 50 | y_morph = np.sin(x_squeezed) |
50 | 51 | low_extrap = np.where(x_morph < x_squeezed[0])[0] |
|
0 commit comments