Skip to content

Commit 6c8d7f0

Browse files
committed
initial commit
created docstring and test function
1 parent 6a0fee3 commit 6c8d7f0

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

diffpy/snmf/subroutines.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,33 @@ def update_weights(components, data_input, method=None):
171171
for i, component in enumerate(components):
172172
stretched_components[:, i] = component.apply_stretch(signal)[0]
173173
if method == 'align':
174-
weights = lsqnonneg(stretched_components, data_input[:,signal])
174+
weights = lsqnonneg(stretched_components, data_input[:, signal])
175175
else:
176176
weights = get_weights(stretched_components.T @ stretched_components,
177177
-stretched_components.T @ data_input[:, signal], 0, 1)
178178
weight_matrix[:, signal] = weights
179179
return weight_matrix
180180

181181

182+
def reconstruct_signal(components, signal_idx):
183+
"""Reconstructs a specific signal from its weighted and stretched components
184+
185+
Parameters
186+
----------
187+
components: tuple of ComponentSignal objects
188+
The tuple containing the ComponentSignal objects
189+
signal_idx: int
190+
The index of the specific signal to be reconstructed
191+
192+
Returns
193+
-------
194+
1d array like
195+
The reconstruction of a signal from calculated weights, stretching factors, and iq values.
196+
197+
"""
198+
pass
199+
200+
182201
def initialize_arrays(number_of_components, number_of_moments, signal_length):
183202
"""Generates the initial guesses for the weight, stretching, and component matrices
184203

diffpy/snmf/tests/test_subroutines.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from diffpy.snmf.containers import ComponentSignal
44
from diffpy.snmf.subroutines import objective_function, get_stretched_component, reconstruct_data, get_residual_matrix, \
55
update_weights_matrix, initialize_arrays, lift_data, initialize_components, construct_stretching_matrix, \
6-
construct_component_matrix, construct_weight_matrix, update_weights
6+
construct_component_matrix, construct_weight_matrix, update_weights, reconstruct_signal
77

88
to = [
99
([[[1, 2], [3, 4]], [[5, 6], [7, 8]], 1e11, [[1, 2], [3, 4]], [[1, 2], [3, 4]], 1], 2.574e14),
@@ -252,3 +252,7 @@ def test_construct_weight_matrix(tcwm):
252252
def test_update_weights(tuw):
253253
actual = update_weights(tuw[0], tuw[1], tuw[2])
254254
assert np.shape(actual) == (len(tuw[0]), len(tuw[0][0].weights))
255+
trs = []
256+
@pytest.mark.parametrize('trs',trs)
257+
def test_reconstruct_signal(trs):
258+
assert False

0 commit comments

Comments
 (0)