Skip to content

Commit 8ab28f6

Browse files
committed
test cases
1 parent 71eadd7 commit 8ab28f6

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

diffpy/snmf/subroutines.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ def construct_component_matrix(components):
110110
component_matrix[i] = component.iq
111111
return component_matrix
112112

113+
113114
def construct_weight_matrix(components):
114115
"""Constructs the weights matrix
115116

diffpy/snmf/tests/test_subroutines.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import numpy as np
33
from diffpy.snmf.containers import ComponentSignal
44
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, construct_component_matrix
5+
update_weights_matrix, initialize_arrays, lift_data, initialize_components, construct_stretching_matrix, construct_component_matrix, construct_weight_matrix
66

77
to = [
88
([[[1, 2], [3, 4]], [[5, 6], [7, 8]], 1e11, [[1, 2], [3, 4]], [[1, 2], [3, 4]], 1], 2.574e14),
@@ -207,6 +207,19 @@ def test_construct_component_matrix(tccm):
207207
for component in tccm:
208208
np.testing.assert_allclose(actual[component.id], component.iq)
209209

210-
211-
def test_construct_weight_matrix():
212-
assert False
210+
tcwm = [
211+
([ComponentSignal([0,.25,.5,.75,1],20,0)]),
212+
([ComponentSignal([0,.25,.5,.75,1],0,0)]),
213+
([ComponentSignal([0,.25,.5,.75,1],20,0),ComponentSignal([0,.25,.5,.75,1],20,1),ComponentSignal([0,.25,.5,.75,1],20,2)]),
214+
([ComponentSignal([0, .25, .5, .75, 1], 20, 0), ComponentSignal([0, .25, .5, .75, 1], 20, 1),
215+
ComponentSignal([0, .25, .5, .75, 1], 20, 2)]),
216+
([ComponentSignal([0, .25, .5, .75, 1], 20, 0), ComponentSignal([0, .25, .5, 2.75, 1], 20, 1),
217+
ComponentSignal([0, .25, .5, .75, 1], 20, 2)]),
218+
([ComponentSignal([.25], 20, 0), ComponentSignal([.25], 20, 1), ComponentSignal([.25], 20, 2)]),
219+
([ComponentSignal([0, .25, .5, .75, 1], 20, 0), ComponentSignal([0, .25, .5, .75, 1], 20, 1)]),
220+
]
221+
@pytest.mark.parametrize('tcwm',tcwm)
222+
def test_construct_weight_matrix(tcwm):
223+
actual = construct_weight_matrix(tcwm)
224+
for component in tcwm:
225+
np.testing.assert_allclose(actual[component.id], component.weights)

0 commit comments

Comments
 (0)