Skip to content

Commit a95f83c

Browse files
committed
added test cases
1 parent 0348510 commit a95f83c

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

diffpy/snmf/tests/test_subroutines.py

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import pytest
22
import numpy as np
3+
from diffpy.snmf.containers import ComponentSignal
34
from diffpy.snmf.subroutines import objective_function, get_stretched_component, reconstruct_data, get_residual_matrix, \
4-
update_weights_matrix, initialize_arrays, lift_data, initialize_components
5+
update_weights_matrix, initialize_arrays, lift_data, initialize_components, construct_stretching_matrix
56

67
to = [
78
([[[1, 2], [3, 4]], [[5, 6], [7, 8]], 1e11, [[1, 2], [3, 4]], [[1, 2], [3, 4]], 1], 2.574e14),
@@ -162,6 +163,25 @@ def test_initialize_components(tcc):
162163
assert len(actual[0].weights) == tcc[1]
163164
assert (actual[0].grid == np.array(tcc[2])).all()
164165

165-
tcso =[]
166-
def test_construct_stretching_matrix():
167-
assert False
166+
tcso =[([ComponentSignal([0,.5,1,1.5],20,0)],1,20),
167+
([ComponentSignal([0,.5,1,1.5],20,0)],4,20),
168+
([ComponentSignal([0,.5,1,1.5],20,0)],0,20),
169+
([ComponentSignal([0,.5,1,1.5],20,0)],-2,20),
170+
([ComponentSignal([0,.5,1,1.5],20,0)],1,0),
171+
([ComponentSignal([0,.5,1,1.5],20,0)],1,-3),
172+
([ComponentSignal([0,.5,1,1.5],20,0),ComponentSignal([0,.5,1,1.5],20,1)],1,20),
173+
([ComponentSignal([0,.5,1,1.5],20,0),ComponentSignal([0,.5,1,21.5],20,1)],1,20),
174+
([ComponentSignal([0,1,1.5],20,0),ComponentSignal([0,.5,1,21.5],20,1)],1,20),
175+
([ComponentSignal([0,.5,1,1.5],20,0),ComponentSignal([0,.5,1,1.5],20,1)],1,-3),
176+
([],1,20),
177+
([],-1,20),
178+
([],0,20),
179+
([],1,0),
180+
([],-1,-2),
181+
182+
]
183+
@pytest.mark.parametrize('tcso',tcso)
184+
def test_construct_stretching_matrix(tcso):
185+
actual = construct_stretching_matrix(tcso[0],tcso[1],tcso[2])
186+
for component in tcso[0]:
187+
assert actual[component.id, :] == component.stretching_factors

0 commit comments

Comments
 (0)