|
2 | 2 | import numpy as np
|
3 | 3 | from diffpy.snmf.containers import ComponentSignal
|
4 | 4 | from diffpy.snmf.subroutines import objective_function, get_stretched_component, reconstruct_data, get_residual_matrix, \
|
5 |
| - update_weights_matrix, initialize_arrays, lift_data, initialize_components, construct_stretching_matrix |
| 5 | + update_weights_matrix, initialize_arrays, lift_data, initialize_components, construct_stretching_matrix, construct_component_matrix |
6 | 6 |
|
7 | 7 | to = [
|
8 | 8 | ([[[1, 2], [3, 4]], [[5, 6], [7, 8]], 1e11, [[1, 2], [3, 4]], [[1, 2], [3, 4]], 1], 2.574e14),
|
@@ -186,3 +186,23 @@ def test_construct_stretching_matrix(tcso):
|
186 | 186 | for component in tcso[0]:
|
187 | 187 | np.testing.assert_allclose(actual[component.id,:], component.stretching_factors)
|
188 | 188 | #assert actual[component.id, :] == component.stretching_factors
|
| 189 | + |
| 190 | +tccm = [ |
| 191 | + ([ComponentSignal([0,.25,.5,.75,1],20,0)]), |
| 192 | + ([ComponentSignal([0,.25,.5,.75,1],0,0)]), |
| 193 | + ([ComponentSignal([0,.25,.5,.75,1],20,0),ComponentSignal([0,.25,.5,.75,1],20,1),ComponentSignal([0,.25,.5,.75,1],20,2)]), |
| 194 | + ([ComponentSignal([0, .25, .5, .75, 1], 20, 0), ComponentSignal([0, .25, .5, .75, 1], 20, 1), |
| 195 | + ComponentSignal([0, .25, .5, .75, 1], 20, 2)]), |
| 196 | + ([ComponentSignal([0, .25, .5, .75, 1], 20, 0), ComponentSignal([0, .25, .5, 2.75, 1], 20, 1), |
| 197 | + ComponentSignal([0, .25, .5, .75, 1], 20, 2)]), |
| 198 | + ([ComponentSignal([.25], 20, 0), ComponentSignal([.25], 20, 1), ComponentSignal([.25], 20, 2)]), |
| 199 | + ([ComponentSignal([0, .25, .5, .75, 1], 20, 0), ComponentSignal([0, .25, .5, .75, 1], 20, 1)]), |
| 200 | + # ([ComponentSignal([[0, .25, .5, .75, 1],[0, .25, .5, .75, 1]], 20, 0), ComponentSignal([[0, .25, .5, .75, 1],[0, .25, .5, .75, 1]], 20, 1)]), # iq is multidimensional. Expected to fail |
| 201 | + # (ComponentSignal([], 20, 0)), # Expected to fail |
| 202 | + # ([]), #Expected to fail |
| 203 | + ] |
| 204 | +@pytest.mark.parametrize('tccm',tccm) |
| 205 | +def test_construct_component_matrix(tccm): |
| 206 | + actual = construct_component_matrix(tccm) |
| 207 | + for component in tccm: |
| 208 | + np.testing.assert_allclose(actual[component.id], component.iq) |
0 commit comments