|
1 | 1 | import pytest |
2 | 2 | import numpy as np |
3 | 3 | from diffpy.snmf.subroutines import objective_function, get_stretched_component, reconstruct_data, get_residual_matrix, \ |
4 | | - update_weights_matrix |
| 4 | + update_weights_matrix, initialize_arrays, lift_data |
5 | 5 |
|
6 | 6 | to = [ |
7 | 7 | ([[[1, 2], [3, 4]], [[5, 6], [7, 8]], 1e11, [[1, 2], [3, 4]], [[1, 2], [3, 4]], 1], 2.574e14), |
@@ -134,3 +134,18 @@ def test_reconstruct_data(trd): |
134 | 134 | actual = reconstruct_data(trd[0][0], trd[0][1], trd[0][2], trd[0][3], trd[0][4], trd[0][5]) |
135 | 135 | expected = trd[1] |
136 | 136 | np.testing.assert_allclose(actual, expected, rtol=1e-03) |
| 137 | + |
| 138 | + |
| 139 | +tld = [(([[[1, -1, 1], [0, 0, 0], [2, 10, -3]], 1]), ([[4, 2, 4], [3, 3, 3], [5, 13, 0]])), |
| 140 | + (([[[1, -1, 1], [0, 0, 0], [2, 10, -3]], 0]), ([[1, -1, 1], [0, 0, 0], [2, 10, -3]])), |
| 141 | + (([[[1, -1, 1], [0, 0, 0], [2, 10, -3]], .5]), ([[2.5, .5, 2.5], [1.5, 1.5, 1.5], [3.5, 11.5, -1.5]])), |
| 142 | + (([[[1, -1, 1], [0, 0, 0], [2, 10, -3]], -1]), ([[4, 2, 4], [3, 3, 3], [5, 13, 0]])), |
| 143 | + (([[[0, 0, 0], [0, 0, 0], [0, 0, 0]], 100]), ([[0, 0, 0], [0, 0, 0], [0, 0, 0]])), |
| 144 | + (([[[1.5, 2], [10.5, 1], [0.5, 2]], 1]), ([[2, 2.5], [11, 1.5], [1, 2.5]])), |
| 145 | + (([[[-10, -10.5], [-12.2, -12.2], [0, 0]], 1]), ([[2.2, 1.7], [0, 0], [12.2, 12.2]])), |
| 146 | + ] |
| 147 | +@pytest.mark.parametrize('tld', tld) |
| 148 | +def test_lift_data(tld): |
| 149 | + actual = lift_data(tld[0][0], tld[0][1]) |
| 150 | + expected = tld[1] |
| 151 | + np.testing.assert_allclose(actual, expected) |
0 commit comments